/* CoralCube | Massively Multiplayer Online Role-Playing Game(MMORPG) Emulator.
|* 
|* Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
|*               2008-2010 TrinityCore <http://www.trinitycore.org/>
|*               2008-2010 CoralCube <http://www.CoralCube.com/>
|*
|* This program is free software. You can redistribute it and/or modify it under the terms of 
|* the GNU General Public License as published by the Free Software Foundation, either 
|* version 2 of the License.
|*
|* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, 
|* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
|* See the GNU General Public License for more details.
|*
|* You should have received a copy of the GNU General Public License along with this program. 
|* If not, see <http://www.gnu.org/licenses/>.
|*/

#include "Common.h"
#include "DatabaseEnv.h"
#include "Config.h"
#include "SystemConfig.h"
#include "Log.h"
#include "Opcodes.h"
#include "WorldSession.h"
#include "WorldPacket.h"
#include "Player.h"
#include "Vehicle.h"
#include "SkillExtraItems.h"
#include "SkillDiscovery.h"
#include "World.h"
#include "AccountMgr.h"
#include "AchievementMgr.h"
#include "AuctionHouseMgr.h"
#include "ObjectMgr.h"
#include "TicketMgr.h"
#include "CreatureEventAIMgr.h"
#include "SpellMgr.h"
#include "Chat.h"
#include "DBCStores.h"
#include "LootMgr.h"
#include "ItemEnchantmentMgr.h"
#include "MapManager.h"
#include "CreatureAIRegistry.h"
#include "BattlegroundMgr.h"
#include "OutdoorPvPMgr.h"
#include "TemporarySummon.h"
#include "WaypointMovementGenerator.h"
#include "VMapFactory.h"
#include "GameEventMgr.h"
#include "PoolMgr.h"
#include "GridNotifiersImpl.h"
#include "CellImpl.h"
#include "InstanceSaveMgr.h"
#include "Util.h"
#include "Language.h"
#include "CreatureGroups.h"
#include "Transport.h"
#include "ProgressBar.h"
#include "ScriptMgr.h"
#include "AddonMgr.h"
#include "LFGMgr.h"
#include "ConditionMgr.h"
#include "DisableMgr.h"
#include "CharacterDatabaseCleaner.h"
#include "ScriptMgr.h"
#include "WeatherMgr.h"
#include "CreatureTextMgr.h"
#include "BattlefieldMgr.h"
#include "AuctionHouseBot.h"
#include "Log.h"
#include "SmartAI.h"
#include "Channel.h"

volatile bool World::m_stopEvent = false;
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
volatile uint32 World::m_worldLoopCounter = 0;

float World::m_MaxVisibleDistanceOnContinents = DEFAULT_VISIBILITY_DISTANCE;
float World::m_MaxVisibleDistanceInInstances  = DEFAULT_VISIBILITY_INSTANCE;
float World::m_MaxVisibleDistanceInBGArenas   = DEFAULT_VISIBILITY_BGARENAS;

int32 World::m_visibility_notify_periodOnContinents = DEFAULT_VISIBILITY_NOTIFY_PERIOD;
int32 World::m_visibility_notify_periodInInstances  = DEFAULT_VISIBILITY_NOTIFY_PERIOD;
int32 World::m_visibility_notify_periodInBGArenas   = DEFAULT_VISIBILITY_NOTIFY_PERIOD;

#define sc sConfigDB

/// World constructor
World::World()
{
    m_playerLimit = 0;
    m_allowedSecurityLevel = SEC_PLAYER;
    m_allowMovement = true;
    m_ShutdownMask = 0;
    m_ShutdownTimer = 0;
    m_gameTime=time(NULL);
    m_startTime=m_gameTime;
    m_maxActiveSessionCount = 0;
    m_maxQueuedSessionCount = 0;
    m_PlayerCount = 0;
    m_MaxPlayerCount = 0;
    m_NextDailyQuestReset = 0;
    m_NextWeeklyQuestReset = 0;
    m_scheduledScripts = 0;

    m_defaultDbcLocale = LOCALE_enUS;
    m_availableDbcLocaleMask = 0;

    m_updateTimeSum = 0;
    m_updateTimeCount = 0;

    m_isClosed = false;
}

/// World destructor
World::~World()
{
    ///- Empty the kicked session set
    while (!m_sessions.empty())
    {
        // not remove from queue, prevent loading new sessions
        delete m_sessions.begin()->second;
        m_sessions.erase(m_sessions.begin());
    }

    CliCommandHolder* command = NULL;
    while (cliCmdQueue.next(command))
        delete command;

    VMAP::VMapFactory::clear();

    //TODO free addSessQueue
}

/// Find a player in a specified zone
Player* World::FindPlayerInZone(uint32 zone)
{
    ///- circle through active sessions and return the first player found in the zone
    SessionMap::const_iterator itr;
    for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
    {
        if (!itr->second)
            continue;

        Player *player = itr->second->GetPlayer();
        if (!player)
            continue;

        if (player->IsInWorld() && player->GetZoneId() == zone)
        {
            // Used by the weather system. We return the player to broadcast the change weather message to him and all players in the zone.
            return player;
        }
    }
    return NULL;
}

bool World::IsClosed() const
{
    return m_isClosed;
}

void World::SetClosed(bool val)
{
    m_isClosed = val;

    // Invert the value, for simplicity for scripters.
    sScriptMgr.OnOpenStateChange(!val);
}

void World::SetMotd(const std::string& motd)
{
    m_motd = motd;

    sScriptMgr.OnMotdChange(m_motd);
}

const char* World::GetMotd() const
{
    return m_motd.c_str();
}

/// Find a session by its id
WorldSession* World::FindSession(uint32 id) const
{
    SessionMap::const_iterator itr = m_sessions.find(id);

    if (itr != m_sessions.end())
        return itr->second;                                 // also can return NULL for kicked session
    else
        return NULL;
}

/// Remove a given session
bool World::RemoveSession(uint32 id)
{
    ///- Find the session, kick the user, but we can't delete session at this moment to prevent iterator invalidation
    SessionMap::const_iterator itr = m_sessions.find(id);

    if (itr != m_sessions.end() && itr->second)
    {
        if (itr->second->PlayerLoading())
            return false;
        itr->second->KickPlayer();
    }

    return true;
}

void World::AddSession(WorldSession* s)
{
    addSessQueue.add(s);
}

void World::AddSession_(WorldSession* s)
{
    ASSERT (s);

    //NOTE - Still there is race condition in WorldSession* being used in the Sockets

    ///- kick already loaded player with same account (if any) and remove session
    ///- if player is in loading and want to load again, return
    if (!RemoveSession (s->GetAccountId()))
    {
        s->KickPlayer();
        delete s;                                           // session not added yet in session list, so not listed in queue
        return;
    }

    // decrease session counts only at not reconnection case
    bool decrease_session = true;

    // if session already exist, prepare to it deleting at next world update
    // NOTE - KickPlayer() should be called on "old" in RemoveSession()
    {
        SessionMap::const_iterator old = m_sessions.find(s->GetAccountId());

        if (old != m_sessions.end())
        {
            // prevent decrease sessions count if session queued
            if (RemoveQueuedPlayer(old->second))
                decrease_session = false;
            // not remove replaced session form queue if listed
            delete old->second;
        }
    }

    m_sessions[s->GetAccountId()] = s;

    uint32 Sessions = GetActiveAndQueuedSessionCount();
    uint32 pLimit = GetPlayerAmountLimit();
    uint32 QueueSize = GetQueuedSessionCount();             //number of players in the queue

    //so we don't count the user trying to
    //login as a session and queue the socket that we are using
    if (decrease_session)
        --Sessions;

    if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity() == SEC_PLAYER && !HasRecentlyDisconnected(s))
    {
        AddQueuedPlayer (s);
        UpdateMaxSessionCounters();
        sLog.outDetail ("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId(), ++QueueSize);
        return;
    }

    s->SendAuthResponse(AUTH_OK, true);

    s->SendAddonsInfo();

    s->SendClientCacheVersion(sWorld.getIntConfig(CONFIG_CLIENTCACHE_VERSION));

    s->SendTutorialsData();

    UpdateMaxSessionCounters();

    // Updates the population
    if (pLimit > 0)
    {
        float popu = (float)GetActiveSessionCount();              // updated number of users on the server
        popu /= pLimit;
        popu *= 2;
        sLog.outDetail ("Server Population (%f).", popu);
    }
}

bool World::HasRecentlyDisconnected(WorldSession* session)
{
    if (!session)
        return false;

    if (uint32 tolerance = getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
    {
        for (DisconnectMap::iterator i = m_disconnects.begin(); i != m_disconnects.end();)
        {
            if (difftime(i->second, time(NULL)) < tolerance)
            {
                if (i->first == session->GetAccountId())
                    return true;
                ++i;
            }
            else
                m_disconnects.erase(i);
        }
    }
    return false;
}

int32 World::GetQueuePos(WorldSession* sess)
{
    uint32 position = 1;

    for (Queue::const_iterator iter = m_QueuedPlayer.begin(); iter != m_QueuedPlayer.end(); ++iter, ++position)
        if ((*iter) == sess)
            return position;

    return 0;
}

void World::AddQueuedPlayer(WorldSession* sess)
{
    sess->SetInQueue(true);
    m_QueuedPlayer.push_back(sess);

    // The 1st SMSG_AUTH_RESPONSE needs to contain other info too.
    sess->SendAuthResponse(AUTH_WAIT_QUEUE, false, GetQueuePos(sess));
}

bool World::RemoveQueuedPlayer(WorldSession* sess)
{
    // sessions count including queued to remove (if removed_session set)
    uint32 sessions = GetActiveSessionCount();

    uint32 position = 1;
    Queue::iterator iter = m_QueuedPlayer.begin();

    // search to remove and count skipped positions
    bool found = false;

    for (; iter != m_QueuedPlayer.end(); ++iter, ++position)
    {
        if (*iter == sess)
        {
            sess->SetInQueue(false);
            sess->ResetTimeOutTime();
            iter = m_QueuedPlayer.erase(iter);
            found = true;                                   // removing queued session
            break;
        }
    }

    // iter point to next socked after removed or end()
    // position store position of removed socket and then new position next socket after removed

    // if session not queued then we need decrease sessions count
    if (!found && sessions)
        --sessions;

    // accept first in queue
    if ((!m_playerLimit || sessions < m_playerLimit) && !m_QueuedPlayer.empty())
    {
        WorldSession* pop_sess = m_QueuedPlayer.front();
        pop_sess->SetInQueue(false);
        pop_sess->ResetTimeOutTime();
        pop_sess->SendAuthWaitQue(0);
        pop_sess->SendAddonsInfo();

        pop_sess->SendClientCacheVersion(sWorld.getIntConfig(CONFIG_CLIENTCACHE_VERSION));
        pop_sess->SendAccountDataTimes(GLOBAL_CACHE_MASK);
        pop_sess->SendTutorialsData();

        m_QueuedPlayer.pop_front();

        // update iter to point first queued socket or end() if queue is empty now
        iter = m_QueuedPlayer.begin();
        position = 1;
    }

    // update position from iter to end()
    // iter point to first not updated socket, position store new position
    for (; iter != m_QueuedPlayer.end(); ++iter, ++position)
        (*iter)->SendAuthWaitQue(position);

    return found;
}

/// Initialize config values
void World::LoadConfigSettings(bool reload)
{
    if (reload)
    {
        sLog.outConfig("-== Reload World Configurations Settings ==-");
    }
    else
        sLog.outConfig("-== Load World Configurations Settings ==-");

    QueryResult c_01_connection                        = ConfigDatabase.Query("SELECT name,value FROM 01_connection_and_directories");
    QueryResult c_02_performance                       = ConfigDatabase.Query("SELECT name,value FROM 02_performance_settings");
    QueryResult c_03_server_logging                    = ConfigDatabase.Query("SELECT name,value FROM 03_server_logging");
    QueryResult c_04_server_settings                   = ConfigDatabase.Query("SELECT name,value FROM 04_server_settings");
    QueryResult c_05_chat_settings                     = ConfigDatabase.Query("SELECT name,value FROM 05_chat_settings");
    QueryResult c_06_gamemaster_settings               = ConfigDatabase.Query("SELECT name,value FROM 06_gamemaster_settings");
    QueryResult c_07_visibility                        = ConfigDatabase.Query("SELECT name,value FROM 07_visibility_and_radiuses");
    QueryResult c_08_server_rates                      = ConfigDatabase.Query("SELECT name,value FROM 08_server_rates");
    QueryResult c_09_auto_broadcast                    = ConfigDatabase.Query("SELECT name,value FROM 09_auto_broadcast");
    QueryResult c_10_battleground_settings             = ConfigDatabase.Query("SELECT name,value FROM 10_battleground_settings");
    QueryResult c_11_arena_settings                    = ConfigDatabase.Query("SELECT name,value FROM 11_arena_settings");
    QueryResult c_12_network_settings                  = ConfigDatabase.Query("SELECT name,value FROM 12_network_settings");
    QueryResult c_13_auctionhouse_bot_settings         = ConfigDatabase.Query("SELECT name,value FROM 13_auctionhouse_bot_settings");
    QueryResult c_14_console                           = ConfigDatabase.Query("SELECT name,value FROM 14_console_and_remote_access");
    QueryResult c_15_custom_server_options             = ConfigDatabase.Query("SELECT name,value FROM 15_custom_server_options");
    QueryResult c_16_anticheat_settings                = ConfigDatabase.Query("SELECT name,value FROM 16_anticheat_settings");
    QueryResult c_17_wintergrasp_settings              = ConfigDatabase.Query("SELECT name,value FROM 17_wintergrasp_settings");

    uint32 count;

    //connection configs begin
    std::string dataPath                    = "data";
    uint32 i_server_port                    = 8085;
    m_int_configs[CONFIG_DB_PING_INTERVAL]  = 30;
    string_pid_file                         = "";
    string_bind_ip                          = "0.0.0.0";

    if (c_01_connection)                                                 
    {
        sLog.outString("Loading connection settings...");
        barGoLink bar(c_01_connection->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_01_connection->Fetch();

            if (fields[0].GetString() == "DataDir")
                if (fields[1].GetString() != dataPath)
                    dataPath = fields[1].GetString();

            if (fields[0].GetString() == "WorldServerPort")
                if (fields[1].GetUInt32() != i_server_port)
                    i_server_port = fields[1].GetUInt32();

            if (fields[0].GetString() == "MaxPingTime")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_DB_PING_INTERVAL])
                    m_int_configs[CONFIG_DB_PING_INTERVAL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "PidFile")
                if (fields[1].GetString() != string_pid_file)
                    string_pid_file = fields[1].GetString();

            if (fields[0].GetString() == "BindIP")
                if (fields[1].GetString() != string_bind_ip)
                    string_bind_ip = fields[1].GetString();

            ++count;
        }
        while (c_01_connection->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u connection settings", count);
    }                                                                     

    if (dataPath.at(dataPath.length() - 1) != '/' && dataPath.at(dataPath.length() - 1) != '\\')
        dataPath.append("/");

    if (reload)
    {
        if (dataPath != m_dataPath)
            sLog.outError("DataDir option can't be changed at Config DB reload, using current value (%s).", m_dataPath.c_str());

        if (i_server_port != m_int_configs[CONFIG_PORT_WORLD])
            sLog.outError("WorldServerPort option can't be changed at Config DB reload, using current value (%u).", m_int_configs[CONFIG_PORT_WORLD]);
    }
    else
    {
        m_dataPath = dataPath;
        m_int_configs[CONFIG_PORT_WORLD] = i_server_port;
    }

    sLog.outConfig(" ~~~~~~~~~~~~== Connection Settings ==~~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("BindIP is set to --------------------------------------- %s", sc.StringEmpty(string_bind_ip.c_str()));
    sLog.outConfig("DataDir is set to -------------------------------------- %s", sc.StringEmpty(m_dataPath.c_str()));
    sLog.outConfig("MaxPingTime is set to ---------------------------------- %u", m_int_configs[CONFIG_DB_PING_INTERVAL]);
    sLog.outConfig("PidFile is set to -------------------------------------- %s", sc.StringEmpty(string_pid_file.c_str()));
    sLog.outConfig("RealmID is set to -------------------------------------- %u", realmID);
    sLog.outConfig("WorldServerPort is set to ------------------------------ %u", m_int_configs[CONFIG_PORT_WORLD]);

    /// - performance configs begin
    m_int_configs[CONFIG_PLAYER_LIMIT]                      = 100;
    m_int_configs[CONFIG_INTERVAL_LOG_UPDATE]               = 60000;
    m_int_configs[CONFIG_MIN_LOG_UPDATE]                    = 10;
    m_int_configs[CONFIG_NUMTHREADS]                        = 1;
    m_int_configs[CONFIG_LOGDB_CLEARINTERVAL]               = 10;
    m_int_configs[CONFIG_LOGDB_CLEARTIME]                   = 1209600;
    m_int_configs[CONFIG_UPTIME_UPDATE]                     = 10;
    m_int_configs[CONFIG_MAX_OVERSPEED_PINGS]               = 2;
    m_bool_configs[CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY]    = true;
    m_bool_configs[CONFIG_DETECT_POS_COLLISION]             = true;
    m_int_configs[CONFIG_COMPRESSION]                       = 1;
    m_bool_configs[CONFIG_ADDON_CHANNEL]                    = true;
    m_bool_configs[CONFIG_CLEAN_CHARACTER_DB]               = false;
    m_bool_configs[CONFIG_GRID_UNLOAD]                      = true;
    m_int_configs[CONFIG_INTERVAL_SAVE]                     = 900000;
    m_int_configs[CONFIG_INTERVAL_DISCONNECT_TOLERANCE]     = 0;
    m_bool_configs[CONFIG_STATS_SAVE_ONLY_ON_LOGOUT]        = true;
    m_int_configs[CONFIG_MIN_LEVEL_STAT_SAVE]               = 0;
    m_int_configs[CONFIG_INTERVAL_GRIDCLEAN]                = 300000;
    m_int_configs[CONFIG_INTERVAL_MAPUPDATE]                = 100;
    m_int_configs[CONFIG_INTERVAL_CHANGEWEATHER]            = 600000;
    m_int_configs[CONFIG_SOCKET_SELECTTIME]                 = 10000;
    m_int_configs[CONFIG_SOCKET_TIMEOUTTIME]                = 900000;
    m_int_configs[CONFIG_SESSION_ADD_DELAY]                 = 10000;
    m_bool_configs[CONFIG_VMAP_ENABLE_INDOOR]               = true;
    m_bool_configs[CONFIG_VMAP_ENABLE_HEIGHT]               = true;
    m_bool_configs[CONFIG_VMAP_ENABLE_LOS]                  = true;
    m_bool_configs[CONFIG_VMAP_ENABLE_PET_LOS]              = true;
    std::string ignoreSpellIds                              = "";
    m_int_configs[CONFIG_USE_PROCCESSORS]                   = 0;
    m_int_configs[CONFIG_MAX_CORE_STACK_TIME]               = 0;
    m_bool_configs[CONFIG_PROCESS_PRIORITY]                 = false;

    if (c_02_performance)                                               
    {
        sLog.outString("Loading performance settings...");
        barGoLink bar(c_02_performance->GetRowCount());
        count = 1;
        do
        {
            bar.step();
            Field *fields = c_02_performance->Fetch();

            if (QueryResult pLimit = LoginDatabase.PQuery("SELECT plimit FROM realmlist WHERE id = '%u' LIMIT 1", realmID))
            {
                Field *fields = pLimit->Fetch();
                if (fields[0].GetUInt32() != m_int_configs[CONFIG_PLAYER_LIMIT])
                    m_int_configs[CONFIG_PLAYER_LIMIT] = fields[0].GetUInt32();
                else
                    m_int_configs[CONFIG_PLAYER_LIMIT] = 0;		//unlimited @chip?
            }

            if (fields[0].GetString() == "RecordUpdateTimeDiffInterval")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_INTERVAL_LOG_UPDATE])
                    m_int_configs[CONFIG_INTERVAL_LOG_UPDATE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MinRecordUpdateTimeDiff")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MIN_LOG_UPDATE])
                    m_int_configs[CONFIG_MIN_LOG_UPDATE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MapUpdate.Threads")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_NUMTHREADS])
                    m_int_configs[CONFIG_NUMTHREADS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "LogDB.Opt.ClearInterval")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_LOGDB_CLEARINTERVAL])
                    m_int_configs[CONFIG_LOGDB_CLEARINTERVAL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "LogDB.Opt.ClearTime")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_LOGDB_CLEARTIME])
                    m_int_configs[CONFIG_LOGDB_CLEARTIME] = fields[1].GetUInt32();

            if (fields[0].GetString() == "UpdateUptimeInterval")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_UPTIME_UPDATE])
                    m_int_configs[CONFIG_UPTIME_UPDATE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MaxOverspeedPings")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAX_OVERSPEED_PINGS])
                    m_int_configs[CONFIG_MAX_OVERSPEED_PINGS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SaveRespawnTimeImmediately")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY] = true;

            if (fields[0].GetString() == "DetectPosCollision")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_DETECT_POS_COLLISION] = false;

            if (fields[0].GetString() == "Compression")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_COMPRESSION])
                    m_int_configs[CONFIG_COMPRESSION] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AddonChannel")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_ADDON_CHANNEL] = false;

            if (fields[0].GetString() == "CleanCharacterDB")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CLEAN_CHARACTER_DB] = true;

            if (fields[0].GetString() == "GridUnload")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_GRID_UNLOAD] = false;

            if (fields[0].GetString() == "PlayerSaveInterval")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_INTERVAL_SAVE])
                    m_int_configs[CONFIG_INTERVAL_SAVE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "DisconnectToleranceInterval")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_INTERVAL_DISCONNECT_TOLERANCE])
                    m_int_configs[CONFIG_INTERVAL_DISCONNECT_TOLERANCE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "PlayerSave.Stats.SaveOnlyOnLogout")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_STATS_SAVE_ONLY_ON_LOGOUT] = false;

            if (fields[0].GetString() == "PlayerSave.Stats.MinLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MIN_LEVEL_STAT_SAVE])
                    m_int_configs[CONFIG_MIN_LEVEL_STAT_SAVE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "GridCleanUpDelay")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_INTERVAL_GRIDCLEAN])
                    m_int_configs[CONFIG_INTERVAL_GRIDCLEAN] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MapUpdateInterval")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_INTERVAL_MAPUPDATE])
                    m_int_configs[CONFIG_INTERVAL_MAPUPDATE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "ChangeWeatherInterval")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_INTERVAL_CHANGEWEATHER])
                    m_int_configs[CONFIG_INTERVAL_CHANGEWEATHER] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SocketSelectTime")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SOCKET_SELECTTIME])
                    m_int_configs[CONFIG_SOCKET_SELECTTIME] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SocketTimeOutTime")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SOCKET_TIMEOUTTIME])
                    m_int_configs[CONFIG_SOCKET_TIMEOUTTIME] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SessionAddDelay")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SESSION_ADD_DELAY])
                    m_int_configs[CONFIG_SESSION_ADD_DELAY] = fields[1].GetUInt32();

            if (fields[0].GetString() == "vmap.petLOS")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_VMAP_ENABLE_PET_LOS] = false;

            if (fields[0].GetString() == "vmap.enableIndoorCheck")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_VMAP_ENABLE_INDOOR] = false;

            if (fields[0].GetString() == "vmap.enableLOS")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_VMAP_ENABLE_LOS] = false;

            if (fields[0].GetString() == "vmap.enableHeight")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_VMAP_ENABLE_HEIGHT] = false;

            if (fields[0].GetString() == "vmap.ignoreSpellIds")
                if (fields[1].GetString() != ignoreSpellIds)
                    ignoreSpellIds = fields[1].GetString();

            if (fields[0].GetString() == "UseProcessors")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_USE_PROCCESSORS])
                    m_int_configs[CONFIG_USE_PROCCESSORS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "ProcessPriority")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_PROCESS_PRIORITY] = true;

            if (fields[0].GetString() == "MaxCoreStuckTime")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAX_CORE_STACK_TIME])
                    m_int_configs[CONFIG_MAX_CORE_STACK_TIME] = fields[1].GetUInt32();

            ++count;
        }
        while (c_02_performance->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u performance settings", count);
    }                                                                

    SetPlayerAmountLimit(getIntConfig(CONFIG_PLAYER_LIMIT));

    if (int32(m_int_configs[CONFIG_LOGDB_CLEARINTERVAL]) <= 0)
    {
        sLog.outError("LogDB.Opt.ClearInterval (%u) must be > 0, set to default 10.", m_int_configs[CONFIG_LOGDB_CLEARINTERVAL]);
        m_int_configs[CONFIG_LOGDB_CLEARINTERVAL] = 10;
    }
    if (int32(m_int_configs[CONFIG_UPTIME_UPDATE]) <= 0)
    {
        sLog.outError("UpdateUptimeInterval (%u) must be > 0, set to default 10.",m_int_configs[CONFIG_UPTIME_UPDATE]);
        m_int_configs[CONFIG_UPTIME_UPDATE] = 10;
    }
    if (reload)
    {
        m_timers[WUPDATE_CLEANDB].SetInterval(m_int_configs[CONFIG_LOGDB_CLEARINTERVAL] * MINUTE * IN_MILLISECONDS);
        m_timers[WUPDATE_CLEANDB].Reset();
        m_timers[WUPDATE_UPTIME].SetInterval(m_int_configs[CONFIG_UPTIME_UPDATE] * MINUTE * IN_MILLISECONDS);
        m_timers[WUPDATE_UPTIME].Reset();
    }
    if (m_int_configs[CONFIG_MAX_OVERSPEED_PINGS] != 0 && m_int_configs[CONFIG_MAX_OVERSPEED_PINGS] < 2)
    {
        sLog.outError("MaxOverspeedPings (%u) must be in range 2..infinity (or 0 to disable check). Set to 2.", m_int_configs[CONFIG_MAX_OVERSPEED_PINGS]);
        m_int_configs[CONFIG_MAX_OVERSPEED_PINGS] = 2;
    }
    if (m_int_configs[CONFIG_COMPRESSION] < 1 || m_int_configs[CONFIG_COMPRESSION] > 9)
    {
        sLog.outError("Compression level (%u) must be in range 1..9. Using default compression level (1).", m_int_configs[CONFIG_COMPRESSION]);
        m_int_configs[CONFIG_COMPRESSION] = 1;
    }
    if (m_int_configs[CONFIG_INTERVAL_SAVE] < 0)
    {
        sLog.outError("PlayerSaveInterval (%u) must be > 0. Use 1 or greater.", m_int_configs[CONFIG_INTERVAL_SAVE]);
        m_int_configs[CONFIG_INTERVAL_SAVE] = 900000;
    }
    if (m_int_configs[CONFIG_MIN_LEVEL_STAT_SAVE] > MAX_LEVEL)
    {
        sLog.outError("PlayerSave.Stats.MinLevel (%u) must be in range 0..80. Using default, do not save character stats (0).", 
            m_int_configs[CONFIG_MIN_LEVEL_STAT_SAVE]);
        m_int_configs[CONFIG_MIN_LEVEL_STAT_SAVE] = 0;
    }
    if (m_int_configs[CONFIG_INTERVAL_GRIDCLEAN] < MIN_GRID_DELAY)
    {
        sLog.outError("GridCleanUpDelay (%u) must be greater %u. Use this minimal value.", 
            m_int_configs[CONFIG_INTERVAL_GRIDCLEAN], MIN_GRID_DELAY);
        m_int_configs[CONFIG_INTERVAL_GRIDCLEAN] = MIN_GRID_DELAY;
    }
    if (m_int_configs[CONFIG_INTERVAL_MAPUPDATE] < MIN_MAP_UPDATE_DELAY)
    {
        sLog.outError("MapUpdateInterval (%u) must be greater %u. Use this minimal value.", 
            m_int_configs[CONFIG_INTERVAL_MAPUPDATE], MIN_MAP_UPDATE_DELAY);
        m_int_configs[CONFIG_INTERVAL_MAPUPDATE] = MIN_MAP_UPDATE_DELAY;
    }
    if (reload)
    {
        sMapMgr.SetGridCleanUpDelay(m_int_configs[CONFIG_INTERVAL_GRIDCLEAN]);
        sMapMgr.SetMapUpdateInterval(m_int_configs[CONFIG_INTERVAL_MAPUPDATE]);
    }
    if (m_int_configs[CONFIG_INTERVAL_CHANGEWEATHER] < 0)
    {
        sLog.outError("ChangeWeatherInterval (%u) must be > 0. Use 1 or greater.", m_int_configs[CONFIG_INTERVAL_CHANGEWEATHER]);
        m_int_configs[CONFIG_INTERVAL_CHANGEWEATHER] = 600000;
    }
    if (m_int_configs[CONFIG_SOCKET_SELECTTIME] < 0)
    {
        sLog.outError("SocketSelectTime (%u) must be > 0. Use 1 or greater.", m_int_configs[CONFIG_SOCKET_SELECTTIME]);
        m_int_configs[CONFIG_SOCKET_SELECTTIME] = 10000;
    }
    if (m_int_configs[CONFIG_SOCKET_TIMEOUTTIME] < 0)
    {
        sLog.outError("SocketTimeOutTime (%u) must be > 0. Use 1 or greater.", m_int_configs[CONFIG_SOCKET_TIMEOUTTIME]);
        m_int_configs[CONFIG_SOCKET_TIMEOUTTIME] = 900000;
    }
    if (m_int_configs[CONFIG_SESSION_ADD_DELAY] < 0)
    {
        sLog.outError("SessionAddDelay (%u) must be > 0. Use 1 or greater.", m_int_configs[CONFIG_SESSION_ADD_DELAY]);
        m_int_configs[CONFIG_SESSION_ADD_DELAY] = 10000;
    }

    VMAP::VMapFactory::createOrGetVMapManager()->setEnableLineOfSightCalc(getBoolConfig(CONFIG_VMAP_ENABLE_LOS));
    VMAP::VMapFactory::createOrGetVMapManager()->setEnableHeightCalc(getBoolConfig(CONFIG_VMAP_ENABLE_HEIGHT));
    VMAP::VMapFactory::preventSpellsFromBeingTestedForLoS(ignoreSpellIds.c_str());

    if (!getBoolConfig(CONFIG_VMAP_ENABLE_HEIGHT))
        sLog.outError("VMap height checking disabled! Creatures movements and other various things WILL be broken! Expect no support.");

    sLog.outConfig(" ~~~~~~~~~~~== Performance Settings ==~~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("AddonChannel is set to --------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_ADDON_CHANNEL]));
    sLog.outConfig("ChangeWeatherInterval is set to ------------------------ %u", m_int_configs[CONFIG_INTERVAL_CHANGEWEATHER]);
    sLog.outConfig("CleanCharacterDB is set to ----------------------------- %s", sc.ToString(m_bool_configs[CONFIG_CLEAN_CHARACTER_DB]));
    sLog.outConfig("Compression is set to ---------------------------------- %u", m_int_configs[CONFIG_COMPRESSION]);
    sLog.outConfig("DetectPosCollision is set to --------------------------- %s", sc.ToString(m_bool_configs[CONFIG_DETECT_POS_COLLISION]));	
    sLog.outConfig("DisconnectToleranceInterval is set to ------------------ %u", m_int_configs[CONFIG_INTERVAL_DISCONNECT_TOLERANCE]);
    sLog.outConfig("GridCleanUpDelay is set to ----------------------------- %u", m_int_configs[CONFIG_INTERVAL_GRIDCLEAN]);
    sLog.outConfig("GridUnload is set to ----------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_GRID_UNLOAD]));
    sLog.outConfig("LogDB.Opt.ClearInterval is set to ---------------------- %u", m_int_configs[CONFIG_LOGDB_CLEARINTERVAL]);
    sLog.outConfig("LogDB.Opt.ClearTime is set to -------------------------- %u", m_int_configs[CONFIG_LOGDB_CLEARTIME]);
    /* sLog.outConfig("Will clear `logs` table of entries older than %u seconds every %u minutes.", 
    m_int_configs[CONFIG_LOGDB_CLEARTIME], m_int_configs[CONFIG_LOGDB_CLEARINTERVAL]); */
    sLog.outConfig("MapUpdate.Threads is set to ---------------------------- %u", m_int_configs[CONFIG_NUMTHREADS]);
    sLog.outConfig("MapUpdateInterval is set to ---------------------------- %u", m_int_configs[CONFIG_INTERVAL_MAPUPDATE]);
    sLog.outConfig("MaxCoreStuckTime is set to ----------------------------- %u", m_int_configs[CONFIG_MAX_CORE_STACK_TIME]);
    sLog.outConfig("MaxOverspeedPings is set to ---------------------------- %u", m_int_configs[CONFIG_MAX_OVERSPEED_PINGS]);
    sLog.outConfig("MinRecordUpdateTimeDiff is set to ---------------------- %u", m_int_configs[CONFIG_MIN_LOG_UPDATE]);
    sLog.outConfig("Player limit is set to --------------------------------- %u", m_int_configs[CONFIG_PLAYER_LIMIT]);
    sLog.outConfig("PlayerSave.Stats.MinLevel is set to -------------------- %u", m_int_configs[CONFIG_MIN_LEVEL_STAT_SAVE]);
    sLog.outConfig("PlayerSave.Stats.SaveOnlyOnLogout is set to ------------ %s", sc.ToString(m_bool_configs[CONFIG_STATS_SAVE_ONLY_ON_LOGOUT]));
    sLog.outConfig("PlayerSaveInterval is set to --------------------------- %u", m_int_configs[CONFIG_INTERVAL_SAVE]);
    sLog.outConfig("ProcessPriority is set to ------------------------------ %s", sc.ToString(m_bool_configs[CONFIG_PROCESS_PRIORITY]));
    sLog.outConfig("RecordUpdateTimeDiffInterval is set to ----------------- %u", m_int_configs[CONFIG_INTERVAL_LOG_UPDATE]);
    sLog.outConfig("SaveRespawnTimeImmediately is set to ------------------- %s", sc.ToString(m_bool_configs[CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY]));
    sLog.outConfig("SessionAddDelay is set to ------------------------------ %u", m_int_configs[CONFIG_SESSION_ADD_DELAY]);
    sLog.outConfig("SocketSelectTime is set to ----------------------------- %u", m_int_configs[CONFIG_SOCKET_SELECTTIME]);
    sLog.outConfig("SocketTimeOutTime is set to ---------------------------- %u", m_int_configs[CONFIG_SOCKET_TIMEOUTTIME]);
    sLog.outConfig("UpdateUptimeInterval is set to ------------------------- %u", m_int_configs[CONFIG_UPTIME_UPDATE]);
    sLog.outConfig("UseProcessors is set to -------------------------------- %u", m_int_configs[CONFIG_USE_PROCCESSORS]);
    sLog.outConfig("vmap.enableHeight is set to ---------------------------- %s", sc.ToString(m_bool_configs[CONFIG_VMAP_ENABLE_HEIGHT]));
    sLog.outConfig("vmap.enableIndoorCheck is set to ----------------------- %s", sc.ToString(m_bool_configs[CONFIG_VMAP_ENABLE_INDOOR]));
    sLog.outConfig("vmap.enableLOS is set to ------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_VMAP_ENABLE_LOS]));
    sLog.outConfig("vmap.ignoreSpellIds is set to -------------------------- %s", sc.StringEmpty(ignoreSpellIds.c_str()));
    sLog.outConfig("vmap.petLOS is set to ---------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_VMAP_ENABLE_PET_LOS]));
    sLog.outConfig("VMap data directory is: -------------------------------- %s", sc.StringEmpty(m_dataPath.c_str()));

    //server logging configs begin
    m_bool_configs[CONFIG_CHATLOG_CHANNEL]                     = false;
    m_bool_configs[CONFIG_CHATLOG_WHISPER]                     = false;	
    m_bool_configs[CONFIG_CHATLOG_SYSCHAN]                     = false;	
    m_bool_configs[CONFIG_CHATLOG_PARTY]                       = false;
    m_bool_configs[CONFIG_CHATLOG_RAID]                        = false;
    m_bool_configs[CONFIG_CHATLOG_GUILD]                       = false;
    m_bool_configs[CONFIG_CHATLOG_PUBLIC]                      = false;
    m_bool_configs[CONFIG_CHATLOG_ADDON]                       = false;
    m_bool_configs[CONFIG_CHATLOG_BGROUND]                     = false;
    m_bool_configs[CONFIG_ARENA_LOG_EXTENDED_INFO]             = false;
    sc.setBoolConfig(CONFIG_WORLD_LOG_DB_CHAR,                    false);
    sc.setBoolConfig(CONFIG_WORLD_LOG_DB_RA,                      false);
    sc.setBoolConfig(CONFIG_WORLD_LOG_DB_GM,                      false);
    sc.setBoolConfig(CONFIG_WORLD_LOG_DB_CHAT,                    false);
    sc.setBoolConfig(CONFIG_WORLD_LOG_DB_WORLD,                   false);
    sc.setIntConfig(CONFIG_WORLD_LOG_FILTER,                      0);
    sc.setBoolConfig(CONFIG_WORLD_LOG_FILTER_ACHIEVEMENT_UPDATES, true);
    sc.setBoolConfig(CONFIG_WORLD_LOG_FILTER_CREATURE_MOVES,      true);
    sc.setBoolConfig(CONFIG_WORLD_LOG_FILTER_TRANSPORT_MOVES,     true);
    sc.setBoolConfig(CONFIG_WORLD_LOG_FILTER_VISIBILITY_CHANGES,  true);

    if (c_03_server_logging)                                                   
    {
        sLog.outString("Loading server logging settings...");
        barGoLink bar(c_03_server_logging->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_03_server_logging->Fetch();

            if (fields[0].GetString() == "ChatLogs.Channel")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CHATLOG_CHANNEL] = true;

            if (fields[0].GetString() == "ChatLogs.Whisper")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CHATLOG_WHISPER] = true;

            if (fields[0].GetString() == "ChatLogs.SysChan")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CHATLOG_SYSCHAN] = true;

            if (fields[0].GetString() == "ChatLogs.Party")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CHATLOG_PARTY] = true;

            if (fields[0].GetString() == "ChatLogs.Raid")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CHATLOG_RAID] = true;

            if (fields[0].GetString() == "ChatLogs.Guild")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CHATLOG_GUILD] = true;

            if (fields[0].GetString() == "ChatLogs.Public")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CHATLOG_PUBLIC] = true;

            if (fields[0].GetString() == "ChatLogs.Addon")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CHATLOG_ADDON] = true;

            if (fields[0].GetString() == "ChatLogs.Battleground")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CHATLOG_BGROUND] = true;

            if (fields[0].GetString() == "ArenaLog.ExtendedInfo")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ARENA_LOG_EXTENDED_INFO] = true;

            if (fields[0].GetString() == "LogDB.Char")
                if (fields[1].GetBool())
                    sc.setBoolConfig(CONFIG_WORLD_LOG_DB_CHAR, true);

            if (fields[0].GetString() == "LogDB.RA")
                if (fields[1].GetBool())
                    sc.setBoolConfig(CONFIG_WORLD_LOG_DB_RA, true);

            if (fields[0].GetString() == "LogDB.GM")
                if (fields[1].GetBool())
                    sc.setBoolConfig(CONFIG_WORLD_LOG_DB_GM, true);

            if (fields[0].GetString() == "LogDB.Chat")
                if (fields[1].GetBool())
                    sc.setBoolConfig(CONFIG_WORLD_LOG_DB_CHAT, true);

            if (fields[0].GetString() == "LogDB.World")
                if (fields[1].GetBool())
                    sc.setBoolConfig(CONFIG_WORLD_LOG_DB_WORLD, true);

            if (fields[0].GetString() == "LogFilter.AchievementUpdates")
                if (!fields[1].GetBool())
                    sc.setBoolConfig(CONFIG_WORLD_LOG_FILTER_ACHIEVEMENT_UPDATES, false);

            if (fields[0].GetString() == "LogFilter.CreatureMoves")
                if (!fields[1].GetBool())
                    sc.setBoolConfig(CONFIG_WORLD_LOG_FILTER_CREATURE_MOVES, false);

            if (fields[0].GetString() == "LogFilter.TransportMoves")
                if (!fields[1].GetBool())
                    sc.setBoolConfig(CONFIG_WORLD_LOG_FILTER_TRANSPORT_MOVES, false);

            if (fields[0].GetString() == "LogFilter.VisibilityChanges")
                if (!fields[1].GetBool())
                    sc.setBoolConfig(CONFIG_WORLD_LOG_FILTER_VISIBILITY_CHANGES, false);

            if (fields[0].GetString() == "SQLDriverQueryLogging")
                if (!fields[1].GetBool())
                    sc.setBoolConfig(CONFIG_SQLQUERYLOGGING, false);

            ++count;
        }
        while (c_03_server_logging->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u server logging settings", count);
    }                                                                 

    if (sc.getBoolConfig(CONFIG_WORLD_LOG_FILTER_TRANSPORT_MOVES))
    {
        sc.setIntConfig(CONFIG_WORLD_LOG_FILTER, LOG_FILTER_TRANSPORT_MOVES, '|');
    }
    if (sc.getBoolConfig(CONFIG_WORLD_LOG_FILTER_CREATURE_MOVES))
    {
        sc.setIntConfig(CONFIG_WORLD_LOG_FILTER, LOG_FILTER_CREATURE_MOVES, '|');
    }
    if (sc.getBoolConfig(CONFIG_WORLD_LOG_FILTER_VISIBILITY_CHANGES))
    {
        sc.setIntConfig(CONFIG_WORLD_LOG_FILTER, LOG_FILTER_VISIBILITY_CHANGES, '|');
    }
    if (sc.getBoolConfig(CONFIG_WORLD_LOG_FILTER_ACHIEVEMENT_UPDATES))
    {
        sc.setIntConfig(CONFIG_WORLD_LOG_FILTER, LOG_FILTER_ACHIEVEMENT_UPDATES, '|');
    }

    sLog.outConfig(" ~~~~~~~~~~== Server Logging Settings ==~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("ArenaLog.ExtendedInfo is set to ------------------------ %s", sc.ToString(m_bool_configs[CONFIG_ARENA_LOG_EXTENDED_INFO]));
    sLog.outConfig("ChatLogs.Addon is set to ------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_CHATLOG_ADDON]));
    sLog.outConfig("ChatLogs.Battleground is set to ------------------------ %s", sc.ToString(m_bool_configs[CONFIG_CHATLOG_BGROUND]));
    sLog.outConfig("ChatLogs.Channel is set to ----------------------------- %s", sc.ToString(m_bool_configs[CONFIG_CHATLOG_CHANNEL]));
    sLog.outConfig("ChatLogs.Guild is set to ------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_CHATLOG_GUILD]));
    sLog.outConfig("ChatLogs.Party is set to ------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_CHATLOG_PARTY]));
    sLog.outConfig("ChatLogs.Public is set to ------------------------------ %s", sc.ToString(m_bool_configs[CONFIG_CHATLOG_PUBLIC]));
    sLog.outConfig("ChatLogs.Raid is set to -------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_CHATLOG_RAID]));
    sLog.outConfig("ChatLogs.SysChan is set to ----------------------------- %s", sc.ToString(m_bool_configs[CONFIG_CHATLOG_SYSCHAN]));
    sLog.outConfig("ChatLogs.Whisper is set to ----------------------------- %s", sc.ToString(m_bool_configs[CONFIG_CHATLOG_WHISPER]));
    sLog.outConfig("Console.Colors is set to ------------------------------- %s", sc.StringEmpty(sc.console_colors.c_str()));
    sLog.outConfig("Console.Level is set to -------------------------------- %u", sc.getIntConfig(CONFIG_LOG_CONSOLE_LEVEL));
    sLog.outConfig("Log.Dir is set to -------------------------------------- %s", sc.StringEmpty(sc.logs_dir.c_str()));
    sLog.outConfig("LogDB.Char is set to ----------------------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_DB_CHAR)));
    sLog.outConfig("LogDB.Chat is set to ----------------------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_DB_CHAT)));
    sLog.outConfig("LogDB.Enable is set to --------------------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_LOG_DB_ENABLE)));
    sLog.outConfig("LogDB.GM is set to ------------------------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_DB_GM)));
    sLog.outConfig("LogDB.RA is set to ------------------------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_DB_RA)));
    sLog.outConfig("LogDB.World is set to ---------------------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_DB_WORLD)));
    sLog.outConfig("LogFile.Arena is set to -------------------------------- %s", sc.StringEmpty(sc.log_arena.c_str()));
    sLog.outConfig("LogFile.Arena.Timestamp is set to ---------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_ARENA_TIMESTAMP)));
    sLog.outConfig("LogFile.Characters is set to --------------------------- %s", sc.StringEmpty(sc.log_char.c_str()));
    sLog.outConfig("LogFile.Characters.Dump is set to ---------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_CHAR_DUMP)));
    sLog.outConfig("LogFile.Characters.Dump.Separate is set to ------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_CHAR_DUMP_SEPARATE)));
    sLog.outConfig("LogFile.Characters.Dump.SeparateDir is set to ---------- %s", sc.StringEmpty(sc.char_dump_dir.c_str()));
    sLog.outConfig("LogFile.Characters.Timestamp is set to ----------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_CHAR_TIMESTAMP)));
    sLog.outConfig("LogFile.Chat is set to --------------------------------- %s", sc.StringEmpty(sc.log_chat.c_str()));
    sLog.outConfig("LogFile.Chat.Timestamp is set to ----------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_CHAT_TIMESTAMP)));
    sLog.outConfig("LogFile.Config is set to ------------------------------- %s", sc.StringEmpty(sc.log_conf.c_str()));
    sLog.outConfig("LogFile.Config.Timestamp is set to --------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_LOG_CONFIG_TIMESTAMP)));
    sLog.outConfig("LogFile.DBErrors is set to ----------------------------- %s", sc.StringEmpty(sc.log_db.c_str()));
    sLog.outConfig("LogFile.DBErrors.Timestamp is set to ------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_DB_TIMESTAMP)));
    sLog.outConfig("LogFile.Game.World is set to --------------------------- %s", sc.StringEmpty(sc.log_world.c_str()));
    sLog.outConfig("LogFile.Gamemaster is set to --------------------------- %s", sc.StringEmpty(sc.log_gm.c_str()));
    sLog.outConfig("LogFile.Gamemaster.Per.Account is set to --------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_GM_PER_ACCOUNT)));
    sLog.outConfig("LogFile.Gamemaster.Timestamp is set to ----------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_GM_TIMESTAMP)));
    sLog.outConfig("LogFile.Level is set to -------------------------------- %u", sc.getIntConfig(CONFIG_LOG_FILE_LEVEL));
    sLog.outConfig("LogFile.RemoteAccess is set to ------------------------- %s", sc.StringEmpty(sc.log_ra.c_str()));
    sLog.outConfig("LogFile.RemoteAccess.Timestamp is set to --------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_RA_TIMESTAMP)));
    sLog.outConfig("LogFile.SqlDriver is set to ---------------------------- %s", sc.StringEmpty(sc.log_sql.c_str()));
    sLog.outConfig("LogFile.SqlDriver.Timestamp is set to ------------------ %s", sc.ToString(sc.getBoolConfig(CONFIG_LOG_SQL_TIMESTAMP)));
    sLog.outConfig("LogFile.World is set to -------------------------------- %s", sc.StringEmpty(sc.log_file.c_str()));
    sLog.outConfig("LogFile.World.Timestamp is set to ---------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_LOG_FILE_TIMESTAMP)));
    sLog.outConfig("LogFilter.AchievementUpdates is set to ----------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_FILTER_ACHIEVEMENT_UPDATES)));
    sLog.outConfig("LogFilter.CreatureMoves is set to ---------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_FILTER_CREATURE_MOVES)));
    sLog.outConfig("LogFilter.TransportMoves is set to --------------------- %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_FILTER_TRANSPORT_MOVES)));
    sLog.outConfig("LogFilter.VisibilityChanges is set to ------------------ %s", sc.ToString(sc.getBoolConfig(CONFIG_WORLD_LOG_FILTER_VISIBILITY_CHANGES)));

    /// - server settings configs begin
    std::string s_motd                                                       = "Welcome to a CoralCube Server.";  // Set the Message of the day from the config file
    m_int_configs[CONFIG_ENABLE_SINFO_LOGIN]                                 = 0;                                 // get server info on login
    m_float_configs[CONFIG_GROUP_XP_DISTANCE]                                = 74.0f;
    m_float_configs[CONFIG_MAX_RECRUIT_A_FRIEND_DISTANCE]                    = 100.0f;
    m_int_configs[CONFIG_STRICT_PLAYER_NAMES]                                = 0;
    m_int_configs[CONFIG_STRICT_CHARTER_NAMES]                               = 0;
    m_int_configs[CONFIG_STRICT_PET_NAMES]                                   = 0;
    m_int_configs[CONFIG_MIN_PLAYER_NAME]                                    = 2;
    m_int_configs[CONFIG_MIN_CHARTER_NAME]                                   = 2;
    m_int_configs[CONFIG_MIN_PET_NAME]                                       = 2;
    m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED]                        = 0;
    m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED_RACEMASK]               = 0;
    m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED_CLASSMASK]              = 0;
    m_int_configs[CONFIG_CHARACTERS_PER_REALM]                               = 10;
    m_int_configs[CONFIG_CHARACTERS_PER_ACCOUNT]                             = 50;
    m_int_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM]                        = 1;
    m_int_configs[CONFIG_CHARACTER_CREATING_MIN_LEVEL_FOR_HEROIC_CHARACTER]  = 55;
    m_int_configs[CONFIG_SKIP_CINEMATICS]                                    = 0;
    m_int_configs[CONFIG_MIN_DUALSPEC_LEVEL]                                 = 40;
    m_int_configs[CONFIG_START_PLAYER_LEVEL]                                 = 1;
    m_int_configs[CONFIG_START_HEROIC_PLAYER_LEVEL]                          = 55;
    m_int_configs[CONFIG_START_PLAYER_MONEY]                                 = 0;
    m_int_configs[CONFIG_MAX_HONOR_POINTS]                                   = 75000;
    m_int_configs[CONFIG_START_HONOR_POINTS]                                 = 0;								
    m_int_configs[CONFIG_MAX_ARENA_POINTS]                                   = 10000;
    m_int_configs[CONFIG_START_ARENA_POINTS]                                 = 0;
    m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL]            = 60;
    m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE] = 3;
    m_bool_configs[CONFIG_ALL_TAXI_PATHS]                                    = false;
    m_bool_configs[CONFIG_INSTANT_TAXI]                                      = false;
    m_bool_configs[CONFIG_INSTANCE_IGNORE_LEVEL]                             = false;
    m_bool_configs[CONFIG_INSTANCE_IGNORE_RAID]                              = false;
    m_bool_configs[CONFIG_CAST_UNSTUCK]                                      = true;
    m_int_configs[CONFIG_INSTANCE_RESET_TIME_HOUR]                           = 4;
    m_int_configs[CONFIG_INSTANCE_UNLOAD_DELAY]                              = 1800000;
    m_int_configs[CONFIG_MAX_PRIMARY_TRADE_SKILL]                            = 2;
    m_int_configs[CONFIG_MIN_PETITION_SIGNS]                                 = 9;
    m_int_configs[CONFIG_MAIL_DELIVERY_DELAY]                                = HOUR;
    m_bool_configs[CONFIG_SKILL_PROSPECTING]                                 = false;
    m_bool_configs[CONFIG_SKILL_MILLING]                                     = false;
    m_bool_configs[CONFIG_WEATHER]                                           = true;
    m_int_configs[CONFIG_DISABLE_BREATHING]                                  = SEC_CONSOLE;
    m_bool_configs[CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL]                        = false;
    m_int_configs[CONFIG_EVENT_ANNOUNCE]                                     = 0;
    m_int_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF]                          = 4;
    m_int_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF]                         = 7;
    m_bool_configs[CONFIG_QUEST_IGNORE_RAID]                                 = false;
    m_bool_configs[CONFIG_DECLINED_NAMES_USED]                               = false;
    m_bool_configs[CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN]                    = true;
    m_int_configs[CONFIG_INSTANT_LOGOUT]                                     = SEC_MODERATOR;
    m_int_configs[CONFIG_GUILD_EVENT_LOG_COUNT]                              = GUILD_EVENTLOG_MAX_RECORDS;
    m_int_configs[CONFIG_GUILD_BANK_EVENT_LOG_COUNT]                         = GUILD_BANKLOG_MAX_RECORDS;
    m_int_configs[CONFIG_MAX_WHO]                                            = 49;
    m_int_configs[CONFIG_MAX_RESULTS_LOOKUP_COMMANDS]                        = 25;
    m_bool_configs[CONFIG_DUNGEON_FINDER_ENABLE]                             = false;
    m_int_configs[CONFIG_DBC_LOCALE]										 = 255;
    m_bool_configs[CONFIG_BEEP_AT_START]									 = true;
    uint32 i_gametype = 0, i_realmzone = 0, i_maxplayerlvl = DEFAULT_MAX_LEVEL, i_expansion = 2, i_clientCacheId = 0;
    m_bool_configs[CONFIG_ALLOW_TICKETS]                                     = true;

    if (c_04_server_settings)                                                  
    {
        sLog.outString("Loading server settings...");
        barGoLink bar(c_04_server_settings->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_04_server_settings->Fetch();

            if (fields[0].GetString() == "Motd")
                if (fields[1].GetString() != s_motd.c_str())
                    s_motd = fields[1].GetString();

            if (fields[0].GetString() == "Server.LoginInfo")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_ENABLE_SINFO_LOGIN])
                    m_int_configs[CONFIG_ENABLE_SINFO_LOGIN] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MaxGroupXPDistance")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_GROUP_XP_DISTANCE])
                    m_float_configs[CONFIG_GROUP_XP_DISTANCE] = fields[1].GetFloat();

            if (fields[0].GetString() == "MaxRecruitAFriendBonusDistance")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_MAX_RECRUIT_A_FRIEND_DISTANCE])
                    m_float_configs[CONFIG_MAX_RECRUIT_A_FRIEND_DISTANCE] = fields[1].GetFloat();

            if (fields[0].GetString() == "GameType")
                if (fields[1].GetUInt32() != i_gametype)
                    i_gametype = fields[1].GetUInt32();

            if (fields[0].GetString() == "RealmZone")
                if (fields[1].GetUInt32() != i_realmzone)
                    i_realmzone = fields[1].GetUInt32();

            if (fields[0].GetString() == "StrictPlayerNames")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_STRICT_PLAYER_NAMES])
                    m_int_configs[CONFIG_STRICT_PLAYER_NAMES] = fields[1].GetUInt32();

            if (fields[0].GetString() == "StrictCharterNames")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_STRICT_CHARTER_NAMES])
                    m_int_configs[CONFIG_STRICT_CHARTER_NAMES] = fields[1].GetUInt32();

            if (fields[0].GetString() == "StrictPetNames")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_STRICT_PET_NAMES])
                    m_int_configs[CONFIG_STRICT_PET_NAMES] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MinPlayerName")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MIN_PLAYER_NAME])
                    m_int_configs[CONFIG_MIN_PLAYER_NAME] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MinCharterName")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MIN_CHARTER_NAME])
                    m_int_configs[CONFIG_MIN_CHARTER_NAME] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MinPetName")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MIN_PET_NAME])
                    m_int_configs[CONFIG_MIN_PET_NAME] = fields[1].GetUInt32();

            if (fields[0].GetString() == "CharacterCreating.Disabled")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED])
                    m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED] = fields[1].GetUInt32();

            if (fields[0].GetString() == "CharacterCreating.Disabled.RaceMask")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED_RACEMASK])
                    m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED_RACEMASK] = fields[1].GetUInt32();

            if (fields[0].GetString() == "CharacterCreating.Disabled.ClassMask")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED_CLASSMASK])
                    m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED_CLASSMASK] = fields[1].GetUInt32();

            if (fields[0].GetString() == "CharactersPerRealm")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHARACTERS_PER_REALM])
                    m_int_configs[CONFIG_CHARACTERS_PER_REALM] = fields[1].GetUInt32();

            if (fields[0].GetString() == "CharactersPerAccount")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHARACTERS_PER_ACCOUNT])
                    m_int_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = fields[1].GetUInt32();

            if (fields[0].GetString() == "HeroicCharactersPerRealm")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM])
                    m_int_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] = fields[1].GetUInt32();

            if (fields[0].GetString() == "CharacterCreating.MinLevelForHeroicCharacter")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHARACTER_CREATING_MIN_LEVEL_FOR_HEROIC_CHARACTER])
                    m_int_configs[CONFIG_CHARACTER_CREATING_MIN_LEVEL_FOR_HEROIC_CHARACTER] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkipCinematics")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKIP_CINEMATICS])
                    m_int_configs[CONFIG_SKIP_CINEMATICS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MaxPlayerLevel")
                if (fields[1].GetUInt32() != i_maxplayerlvl)
                    i_maxplayerlvl = fields[1].GetUInt32();

            if (fields[0].GetString() == "MinDualSpecLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MIN_DUALSPEC_LEVEL])
                    m_int_configs[CONFIG_MIN_DUALSPEC_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "StartPlayerLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_START_PLAYER_LEVEL])
                    m_int_configs[CONFIG_START_PLAYER_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "StartHeroicPlayerLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_START_HEROIC_PLAYER_LEVEL])
                    m_int_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "StartPlayerMoney")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_START_PLAYER_MONEY])
                    m_int_configs[CONFIG_START_PLAYER_MONEY] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MaxHonorPoints")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAX_HONOR_POINTS])
                    m_int_configs[CONFIG_MAX_HONOR_POINTS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "StartHonorPoints")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_START_HONOR_POINTS])
                    m_int_configs[CONFIG_START_HONOR_POINTS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MaxArenaPoints")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAX_ARENA_POINTS])
                    m_int_configs[CONFIG_MAX_ARENA_POINTS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "StartArenaPoints")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_START_ARENA_POINTS])
                    m_int_configs[CONFIG_START_ARENA_POINTS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "RecruitAFriend.MaxLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL])
                    m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "RecruitAFriend.MaxDifference")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE])
                    m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AllFlightPaths")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALL_TAXI_PATHS] = true;

            if (fields[0].GetString() == "InstantFlightPaths")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_INSTANT_TAXI] = true;

            if (fields[0].GetString() == "Instance.IgnoreLevel")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_INSTANCE_IGNORE_LEVEL] = true;

            if (fields[0].GetString() == "Instance.IgnoreRaid")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_INSTANCE_IGNORE_RAID] = true;

            if (fields[0].GetString() == "CastUnstuck")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_CAST_UNSTUCK] = false;

            if (fields[0].GetString() == "Instance.ResetTimeHour")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_INSTANCE_RESET_TIME_HOUR])
                    m_int_configs[CONFIG_INSTANCE_RESET_TIME_HOUR] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Instance.UnloadDelay")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_INSTANCE_UNLOAD_DELAY])
                    m_int_configs[CONFIG_INSTANCE_UNLOAD_DELAY] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MaxPrimaryTradeSkill")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAX_PRIMARY_TRADE_SKILL])
                    m_int_configs[CONFIG_MAX_PRIMARY_TRADE_SKILL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MinPetitionSigns")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MIN_PETITION_SIGNS])
                    m_int_configs[CONFIG_MIN_PETITION_SIGNS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MailDeliveryDelay")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAIL_DELIVERY_DELAY])
                    m_int_configs[CONFIG_MAIL_DELIVERY_DELAY] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkillChance.Prospecting")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_SKILL_PROSPECTING] = true;

            if (fields[0].GetString() == "SkillChance.Milling")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_SKILL_MILLING] = true;

            if (fields[0].GetString() == "ActivateWeather")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_WEATHER] = false;

            if (fields[0].GetString() == "DisableWaterBreath")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_DISABLE_BREATHING])
                    m_int_configs[CONFIG_DISABLE_BREATHING] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AlwaysMaxSkillForLevel")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL] = true;

            if (fields[0].GetString() == "Expansion")
                if (fields[1].GetUInt32() != i_expansion)
                    i_expansion = fields[1].GetUInt32();

            if (fields[0].GetString() == "Event.Announce")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_EVENT_ANNOUNCE])
                    m_int_configs[CONFIG_EVENT_ANNOUNCE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Quests.LowLevelHideDiff")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF])
                    m_int_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Quests.HighLevelHideDiff")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF])
                    m_int_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Quests.IgnoreRaid")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_QUEST_IGNORE_RAID] = true;

            if (fields[0].GetString() == "DeclinedNames")
                if ((m_int_configs[CONFIG_REALM_ZONE] == REALM_ZONE_RUSSIAN) || (fields[1].GetBool()))
                    m_bool_configs[CONFIG_DECLINED_NAMES_USED] = true;

            if (fields[0].GetString() == "OffhandCheckAtSpellUnlearn")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN] = false;

            if (fields[0].GetString() == "ClientCacheVersion")
                if (fields[1].GetUInt32() != i_clientCacheId)
                    i_clientCacheId = fields[1].GetUInt32();

            if (fields[0].GetString() == "InstantLogout")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_INSTANT_LOGOUT])
                    m_int_configs[CONFIG_INSTANT_LOGOUT] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Guild.EventLogRecordsCount")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_GUILD_EVENT_LOG_COUNT])
                    m_int_configs[CONFIG_GUILD_EVENT_LOG_COUNT] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Guild.BankEventLogRecordsCount")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_GUILD_BANK_EVENT_LOG_COUNT])
                    m_int_configs[CONFIG_GUILD_BANK_EVENT_LOG_COUNT] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MaxWhoListReturns")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAX_WHO])
                    m_int_configs[CONFIG_MAX_WHO] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Command.LookupMaxResults")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAX_RESULTS_LOOKUP_COMMANDS])
                    m_int_configs[CONFIG_MAX_RESULTS_LOOKUP_COMMANDS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "DungeonFinder.Enable")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_DUNGEON_FINDER_ENABLE] = true;

            if (fields[0].GetString() == "DBC.Locale")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_DBC_LOCALE])
                    m_int_configs[CONFIG_DBC_LOCALE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "BeepAtStart")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_BEEP_AT_START] = false;

            ///- Read ticket system setting from the config file
            if (fields[0].GetString() == "AllowTickets")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TICKETS] = true;

            if (fields[0].GetString() == "DBC.EnforceItemAttributes")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_DBC_ENFORCE_ITEM_ATTRIBUTES] = true;

            ++count;
        }
        while (c_04_server_settings->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u server settings", count);
    }                                                                    

    SetMotd(s_motd.c_str());

    if (reload)
    {
        if (i_gametype != m_int_configs[CONFIG_GAME_TYPE])
            sLog.outError("GameType option can't be changed at Config DB reload, using current value (%u).", m_int_configs[CONFIG_GAME_TYPE]);

        if (i_realmzone != m_int_configs[CONFIG_REALM_ZONE])
            sLog.outError("RealmZone option can't be changed at Config DB reload, using current value (%u).", m_int_configs[CONFIG_REALM_ZONE]);

        if (i_maxplayerlvl != m_int_configs[CONFIG_MAX_PLAYER_LEVEL])
            sLog.outError("MaxPlayerLevel option can't be changed at config reload, using current value (%u).", m_int_configs[CONFIG_MAX_PLAYER_LEVEL]);

        if (i_expansion != m_int_configs[CONFIG_EXPANSION])
            sLog.outError("Expansion option can't be changed at Config DB reload, using current value (%u).", m_int_configs[CONFIG_EXPANSION]);
    }
    else
    {
        m_int_configs[CONFIG_GAME_TYPE] = i_gametype;
        m_int_configs[CONFIG_REALM_ZONE] = i_realmzone;	
        m_int_configs[CONFIG_MAX_PLAYER_LEVEL] = i_maxplayerlvl;
        m_int_configs[CONFIG_EXPANSION] = i_expansion;
    }

    if (m_int_configs[CONFIG_MIN_PLAYER_NAME] < 1 || m_int_configs[CONFIG_MIN_PLAYER_NAME] > MAX_PLAYER_NAME)
    {
        sLog.outError("MinPlayerName (%u) must be in range 1..%u. Set to 2.", m_int_configs[CONFIG_MIN_PLAYER_NAME], MAX_PLAYER_NAME);
        m_int_configs[CONFIG_MIN_PLAYER_NAME] = 2;
    }
    if (m_int_configs[CONFIG_MIN_CHARTER_NAME] < 1 || m_int_configs[CONFIG_MIN_CHARTER_NAME] > MAX_CHARTER_NAME)
    {
        sLog.outError("MinCharterName (%u) must be in range 1..%u. Set to 2.", m_int_configs[CONFIG_MIN_CHARTER_NAME], MAX_CHARTER_NAME);
        m_int_configs[CONFIG_MIN_CHARTER_NAME] = 2;
    }
    if (m_int_configs[CONFIG_MIN_PET_NAME] < 1 || m_int_configs[CONFIG_MIN_PET_NAME] > MAX_PET_NAME)
    {
        sLog.outError("MinPetName (%u) must be in range 1..%u. Set to 2.", m_int_configs[CONFIG_MIN_PET_NAME], MAX_PET_NAME);
        m_int_configs[CONFIG_MIN_PET_NAME] = 2;
    }    
    if (m_int_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_int_configs[CONFIG_CHARACTERS_PER_REALM] > 10)
    {
        sLog.outError("CharactersPerRealm (%u) must be in range 1..10. Set to 10.", m_int_configs[CONFIG_CHARACTERS_PER_REALM]);
        m_int_configs[CONFIG_CHARACTERS_PER_REALM] = 10;
    }
    if (m_int_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < m_int_configs[CONFIG_CHARACTERS_PER_REALM])
    {
        sLog.outError("CharactersPerAccount (%u) can't be less than CharactersPerRealm (%u).", 
            m_int_configs[CONFIG_CHARACTERS_PER_ACCOUNT], m_int_configs[CONFIG_CHARACTERS_PER_REALM]);
        m_int_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = m_int_configs[CONFIG_CHARACTERS_PER_REALM];
    }
    if (int32(m_int_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM]) < 0 || m_int_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] > 10)
    {
        sLog.outError("HeroicCharactersPerRealm (%u) must be in range 0..10. Set to 1.", m_int_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM]);
        m_int_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM] = 1;
    }	
    if (int32(m_int_configs[CONFIG_SKIP_CINEMATICS]) < 0 || m_int_configs[CONFIG_SKIP_CINEMATICS] > 2)
    {
        sLog.outError("SkipCinematics (%u) must be in range 0..2. Set to 0.",m_int_configs[CONFIG_SKIP_CINEMATICS]);
        m_int_configs[CONFIG_SKIP_CINEMATICS] = 0;
    }
    if (m_int_configs[CONFIG_MAX_PLAYER_LEVEL] > MAX_LEVEL)
    {
        sLog.outError("MaxPlayerLevel (%u) must be in range 1..%u. Set to %u.", 
            m_int_configs[CONFIG_MAX_PLAYER_LEVEL], MAX_LEVEL, MAX_LEVEL);
        m_int_configs[CONFIG_MAX_PLAYER_LEVEL] = MAX_LEVEL;
    }
    if (m_int_configs[CONFIG_START_PLAYER_LEVEL] < 1)
    {
        sLog.outError("StartPlayerLevel (%u) must be in range 1..MaxPlayerLevel(%u). Set to 1.", 
            m_int_configs[CONFIG_START_PLAYER_LEVEL], m_int_configs[CONFIG_MAX_PLAYER_LEVEL]);
        m_int_configs[CONFIG_START_PLAYER_LEVEL] = 1;
    }
    else if (m_int_configs[CONFIG_START_PLAYER_LEVEL] > m_int_configs[CONFIG_MAX_PLAYER_LEVEL])
    {
        sLog.outError("StartPlayerLevel (%u) must be in range 1..MaxPlayerLevel(%u). Set to %u.", 
            m_int_configs[CONFIG_START_PLAYER_LEVEL], m_int_configs[CONFIG_MAX_PLAYER_LEVEL], m_int_configs[CONFIG_MAX_PLAYER_LEVEL]);
        m_int_configs[CONFIG_START_PLAYER_LEVEL] = m_int_configs[CONFIG_MAX_PLAYER_LEVEL];
    }
    if (m_int_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] < 1)
    {
        sLog.outError("StartHeroicPlayerLevel (%u) must be in range 1..MaxPlayerLevel(%u). Set to 55.",
            m_int_configs[CONFIG_START_HEROIC_PLAYER_LEVEL],m_int_configs[CONFIG_MAX_PLAYER_LEVEL]);
        m_int_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] = 55;
    }
    else if (m_int_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] > m_int_configs[CONFIG_MAX_PLAYER_LEVEL])
    {
        sLog.outError("StartHeroicPlayerLevel (%u) must be in range 1..MaxPlayerLevel(%u). Set to %u.",
            m_int_configs[CONFIG_START_HEROIC_PLAYER_LEVEL], m_int_configs[CONFIG_MAX_PLAYER_LEVEL], m_int_configs[CONFIG_MAX_PLAYER_LEVEL]);
        m_int_configs[CONFIG_START_HEROIC_PLAYER_LEVEL] = m_int_configs[CONFIG_MAX_PLAYER_LEVEL];
    }
    if (int32(m_int_configs[CONFIG_START_PLAYER_MONEY]) < 0)
    {
        sLog.outError("StartPlayerMoney (%u) must be in range 0..%u. Set to %u.", 
            m_int_configs[CONFIG_START_PLAYER_MONEY], MAX_MONEY_AMOUNT, 0);
        m_int_configs[CONFIG_START_PLAYER_MONEY] = 0;
    }
    else if (m_int_configs[CONFIG_START_PLAYER_MONEY] > MAX_MONEY_AMOUNT)
    {
        sLog.outError("StartPlayerMoney (%u) must be in range 0..%u. Set to %u.", 
            m_int_configs[CONFIG_START_PLAYER_MONEY], MAX_MONEY_AMOUNT, MAX_MONEY_AMOUNT);
        m_int_configs[CONFIG_START_PLAYER_MONEY] = MAX_MONEY_AMOUNT;
    }
    if (int32(m_int_configs[CONFIG_MAX_HONOR_POINTS]) < 0)
    {
        sLog.outError("MaxHonorPoints (%u) can't be negative. Set to 0.", m_int_configs[CONFIG_MAX_HONOR_POINTS]);
        m_int_configs[CONFIG_MAX_HONOR_POINTS] = 0;
    }
    if (int32(m_int_configs[CONFIG_START_HONOR_POINTS]) < 0)
    {
        sLog.outError("StartHonorPoints (%u) must be in range 0..MaxHonorPoints(%u). Set to %u.", 
            m_int_configs[CONFIG_START_HONOR_POINTS], m_int_configs[CONFIG_MAX_HONOR_POINTS],0);
        m_int_configs[CONFIG_START_HONOR_POINTS] = 0;
    }
    else if (m_int_configs[CONFIG_START_HONOR_POINTS] > m_int_configs[CONFIG_MAX_HONOR_POINTS])
    {
        sLog.outError("StartHonorPoints (%u) must be in range 0..MaxHonorPoints(%u). Set to %u.", 
            m_int_configs[CONFIG_START_HONOR_POINTS], m_int_configs[CONFIG_MAX_HONOR_POINTS], m_int_configs[CONFIG_MAX_HONOR_POINTS]);
        m_int_configs[CONFIG_START_HONOR_POINTS] = m_int_configs[CONFIG_MAX_HONOR_POINTS];
    }
    if (int32(m_int_configs[CONFIG_MAX_ARENA_POINTS]) < 0)
    {
        sLog.outError("MaxArenaPoints (%u) can't be negative. Set to 0.", m_int_configs[CONFIG_MAX_ARENA_POINTS]);
        m_int_configs[CONFIG_MAX_ARENA_POINTS] = 0;
    }
    if (int32(m_int_configs[CONFIG_START_ARENA_POINTS]) < 0)
    {
        sLog.outError("StartArenaPoints (%u) must be in range 0..MaxArenaPoints(%u). Set to %u.",
            m_int_configs[CONFIG_START_ARENA_POINTS],m_int_configs[CONFIG_MAX_ARENA_POINTS],0);
        m_int_configs[CONFIG_START_ARENA_POINTS] = 0;
    }
    else if (m_int_configs[CONFIG_START_ARENA_POINTS] > m_int_configs[CONFIG_MAX_ARENA_POINTS])
    {
        sLog.outError("StartArenaPoints (%u) must be in range 0..MaxArenaPoints(%u). Set to %u.", 
            m_int_configs[CONFIG_START_ARENA_POINTS], m_int_configs[CONFIG_MAX_ARENA_POINTS], m_int_configs[CONFIG_MAX_ARENA_POINTS]);
        m_int_configs[CONFIG_START_ARENA_POINTS] = m_int_configs[CONFIG_MAX_ARENA_POINTS];
    }
    if (m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL] > m_int_configs[CONFIG_MAX_PLAYER_LEVEL])
    {
        sLog.outError("RecruitAFriend.MaxLevel (%u) must be in the range 0..MaxLevel(%u). Set to %u.", 
            m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL], m_int_configs[CONFIG_MAX_PLAYER_LEVEL], 60);
        m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL] = 60;
    }
    if (m_int_configs[CONFIG_MIN_PETITION_SIGNS] > 9)
    {
        sLog.outError("MinPetitionSigns (%u) must be in range 0..9. Set to 9.", m_int_configs[CONFIG_MIN_PETITION_SIGNS]);
        m_int_configs[CONFIG_MIN_PETITION_SIGNS] = 9;
    }
    if (m_int_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] > MAX_LEVEL)
    {
        m_int_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF] = MAX_LEVEL;
    }
    if (m_int_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] > MAX_LEVEL)
    {
        m_int_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF] = MAX_LEVEL;
    }
    if (i_clientCacheId > 0)
    {
        m_int_configs[CONFIG_CLIENTCACHE_VERSION] = i_clientCacheId;
    }
    else if (i_clientCacheId < 0)
    {
        sLog.outError("ClientCacheVersion can't be negative %u, ignored.", i_clientCacheId);
    }
    if (m_int_configs[CONFIG_GUILD_EVENT_LOG_COUNT] < GUILD_EVENTLOG_MAX_RECORDS)
    {
        m_int_configs[CONFIG_GUILD_EVENT_LOG_COUNT] = GUILD_EVENTLOG_MAX_RECORDS;
    }
    if (m_int_configs[CONFIG_GUILD_BANK_EVENT_LOG_COUNT] < GUILD_BANKLOG_MAX_RECORDS)
    {
        m_int_configs[CONFIG_GUILD_BANK_EVENT_LOG_COUNT] = GUILD_BANKLOG_MAX_RECORDS;
    }

    sLog.outConfig(" ~~~~~~~~~~~~~~== Server Settings ==~~~~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("ActivateWeather is set to ------------------------------ %s", sc.ToString(m_bool_configs[CONFIG_WEATHER]));
    sLog.outConfig("AllFlightPaths is set to ------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_ALL_TAXI_PATHS]));
    sLog.outConfig("AlwaysMaxSkillForLevel is set to ----------------------- %s", sc.ToString(m_bool_configs[CONFIG_ALWAYS_MAX_SKILL_FOR_LEVEL]));
    sLog.outConfig("BeepAtStart is set to ---------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_BEEP_AT_START]));
    sLog.outConfig("CastUnstuck is set to ---------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_CAST_UNSTUCK]));
    sLog.outConfig("CharacterCreating.Disabled is set to ------------------- %u", m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED]);
    sLog.outConfig("CharacterCreating.Disabled.ClassMask is set to --------- %u", m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED_CLASSMASK]);
    sLog.outConfig("CharacterCreating.Disabled.RaceMask is set to ---------- %u", m_int_configs[CONFIG_CHARACTER_CREATING_DISABLED_RACEMASK]);
    sLog.outConfig("CharacterCreating.MinLevelForHeroicCharacter is set to - %u", m_int_configs[CONFIG_CHARACTER_CREATING_MIN_LEVEL_FOR_HEROIC_CHARACTER]);
    sLog.outConfig("CharactersPerAccount is set to ------------------------- %u", m_int_configs[CONFIG_CHARACTERS_PER_ACCOUNT]);
    sLog.outConfig("CharactersPerRealm is set to --------------------------- %u", m_int_configs[CONFIG_CHARACTERS_PER_REALM]);
    sLog.outConfig("ClientCacheVersion is set to --------------------------- %u", m_int_configs[CONFIG_CLIENTCACHE_VERSION]);
    sLog.outConfig("Command.LookupMaxResults is set to --------------------- %u", m_int_configs[CONFIG_MAX_RESULTS_LOOKUP_COMMANDS]);
    sLog.outConfig("DBC.Locale is set to ----------------------------------- %u", m_int_configs[CONFIG_DBC_LOCALE]);
    sLog.outConfig("DeclinedNames is set to -------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_DECLINED_NAMES_USED]));
    sLog.outConfig("DisableWaterBreath is set to --------------------------- %u", m_int_configs[CONFIG_DISABLE_BREATHING]);
    sLog.outConfig("DungeonFinder.Enable is set to ------------------------- %s", sc.ToString(m_bool_configs[CONFIG_DUNGEON_FINDER_ENABLE]));
    sLog.outConfig("Event.Announce is set to ------------------------------- %u", m_int_configs[CONFIG_EVENT_ANNOUNCE]);
    sLog.outConfig("Expansion is set to ------------------------------------ %u", i_expansion);
    sLog.outConfig("GameType is set to ------------------------------------- %u", m_int_configs[CONFIG_GAME_TYPE]);
    sLog.outConfig("Guild.BankEventLogRecordsCount is set to --------------- %u", m_int_configs[CONFIG_GUILD_BANK_EVENT_LOG_COUNT]);
    sLog.outConfig("Guild.EventLogRecordsCount is set to ------------------- %u", m_int_configs[CONFIG_GUILD_EVENT_LOG_COUNT]);
    sLog.outConfig("HeroicCharactersPerRealm is set to --------------------- %u", m_int_configs[CONFIG_HEROIC_CHARACTERS_PER_REALM]);
    sLog.outConfig("Instance.IgnoreLevel is set to ------------------------- %s", sc.ToString(m_bool_configs[CONFIG_INSTANCE_IGNORE_LEVEL]));
    sLog.outConfig("Instance.IgnoreRaid is set to -------------------------- %s", sc.ToString(m_bool_configs[CONFIG_INSTANCE_IGNORE_RAID]));
    sLog.outConfig("Instance.ResetTimeHour is set to ----------------------- %u", m_int_configs[CONFIG_INSTANCE_RESET_TIME_HOUR]);
    sLog.outConfig("Instance.UnloadDelay is set to ------------------------- %u", m_int_configs[CONFIG_INSTANCE_UNLOAD_DELAY]);
    sLog.outConfig("InstantFlightPaths is set to --------------------------- %s", sc.ToString(m_bool_configs[CONFIG_INSTANT_TAXI]));
    sLog.outConfig("InstantLogout is set to -------------------------------- %u", m_int_configs[CONFIG_INSTANT_LOGOUT]);
    sLog.outConfig("MailDeliveryDelay is set to ---------------------------- %u", m_int_configs[CONFIG_MAIL_DELIVERY_DELAY]);
    sLog.outConfig("MaxArenaPoints is set to ------------------------------- %u", m_int_configs[CONFIG_MAX_ARENA_POINTS]);
    sLog.outConfig("MaxGroupXPDistance is set to --------------------------- %f", m_float_configs[CONFIG_GROUP_XP_DISTANCE]);
    sLog.outConfig("MaxHonorPoints is set to ------------------------------- %u", m_int_configs[CONFIG_MAX_HONOR_POINTS]);
    sLog.outConfig("MaxPlayerLevel is set to ------------------------------- %u", m_int_configs[CONFIG_MAX_PLAYER_LEVEL]);
    sLog.outConfig("MaxPrimaryTradeSkill is set to ------------------------- %u", m_int_configs[CONFIG_MAX_PRIMARY_TRADE_SKILL]);
    sLog.outConfig("MaxRecruitAFriendBonusDistance is set to --------------- %f", m_float_configs[CONFIG_MAX_RECRUIT_A_FRIEND_DISTANCE]);
    sLog.outConfig("MaxWhoListReturns is set to ---------------------------- %u", m_int_configs[CONFIG_MAX_WHO]);
    sLog.outConfig("MinCharterName is set to ------------------------------- %u", m_int_configs[CONFIG_MIN_CHARTER_NAME]);
    sLog.outConfig("MinDualSpecLevel is set to ----------------------------- %u", m_int_configs[CONFIG_MIN_DUALSPEC_LEVEL]);
    sLog.outConfig("MinPetitionSigns is set to ----------------------------- %u", m_int_configs[CONFIG_MIN_PETITION_SIGNS]);
    sLog.outConfig("MinPetName is set to ----------------------------------- %u", m_int_configs[CONFIG_MIN_PET_NAME]);
    sLog.outConfig("MinPlayerName is set to -------------------------------- %u", m_int_configs[CONFIG_MIN_PLAYER_NAME]);
    sLog.outConfig("Motd is set to ----------------------------------------- %s", sc.StringEmpty(s_motd.c_str()));
    sLog.outConfig("OffhandCheckAtSpellUnlearn is set to ------------------- %s", sc.ToString(m_bool_configs[CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN]));
    sLog.outConfig("Quests.HighLevelHideDiff is set to --------------------- %u", m_int_configs[CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF]);
    sLog.outConfig("Quests.IgnoreRaid is set to ---------------------------- %s", sc.ToString(m_bool_configs[CONFIG_QUEST_IGNORE_RAID]));
    sLog.outConfig("Quests.LowLevelHideDiff is set to ---------------------- %u", m_int_configs[CONFIG_QUEST_LOW_LEVEL_HIDE_DIFF]);
    sLog.outConfig("RealmZone is set to ------------------------------------ %u", m_int_configs[CONFIG_REALM_ZONE]);
    sLog.outConfig("RecruitAFriend.MaxDifference is set to ----------------- %u", m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE]);
    sLog.outConfig("RecruitAFriend.MaxLevel is set to ---------------------- %u", m_int_configs[CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL]);
    sLog.outConfig("Server.LoginInfo is set to ----------------------------- %u", m_int_configs[CONFIG_ENABLE_SINFO_LOGIN]);
    sLog.outConfig("SkillChance.Milling is set to -------------------------- %s", sc.ToString(m_bool_configs[CONFIG_SKILL_MILLING]));
    sLog.outConfig("SkillChance.Prospecting is set to ---------------------- %s", sc.ToString(m_bool_configs[CONFIG_SKILL_PROSPECTING]));
    sLog.outConfig("SkipCinematics is set to ------------------------------- %u", m_int_configs[CONFIG_SKIP_CINEMATICS]);
    sLog.outConfig("StartArenaPoints is set to ----------------------------- %u", m_int_configs[CONFIG_START_ARENA_POINTS]);
    sLog.outConfig("StartHeroicPlayerLevel is set to ----------------------- %u", m_int_configs[CONFIG_START_HEROIC_PLAYER_LEVEL]);
    sLog.outConfig("StartHonorPoints is set to ----------------------------- %u", m_int_configs[CONFIG_START_HONOR_POINTS]);
    sLog.outConfig("StartPlayerLevel is set to ----------------------------- %u", m_int_configs[CONFIG_START_PLAYER_LEVEL]);
    sLog.outConfig("StartPlayerMoney is set to ----------------------------- %u", m_int_configs[CONFIG_START_PLAYER_MONEY]);
    sLog.outConfig("StrictCharterNames is set to --------------------------- %u", m_int_configs[CONFIG_STRICT_CHARTER_NAMES]);
    sLog.outConfig("StrictPetNames is set to ------------------------------- %u", m_int_configs[CONFIG_STRICT_PET_NAMES]);
    sLog.outConfig("StrictPlayerNames is set to ---------------------------- %u", m_int_configs[CONFIG_STRICT_PLAYER_NAMES]);

    /// - chat configs begin
    m_int_configs[CONFIG_CHATFLOOD_MESSAGE_COUNT]               = 10;
    m_int_configs[CONFIG_CHATFLOOD_MESSAGE_DELAY]               = 1;
    m_int_configs[CONFIG_CHATFLOOD_MUTE_TIME]                   = 10;
    m_bool_configs[CONFIG_RESTRICTED_LFG_CHANNEL]               = true;
    m_bool_configs[CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL]          = false;
    m_bool_configs[CONFIG_CHAT_FAKE_MESSAGE_PREVENTING]         = false;
    m_int_configs[CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY]    = 0;
    m_int_configs[CONFIG_CHAT_STRICT_LINK_CHECKING_KICK]        = 0;
    m_int_configs[CONFIG_CHAT_CHANNEL_LEVEL_REQ]                = 1;
    m_int_configs[CONFIG_CHAT_WHISPER_LEVEL_REQ]                = 1;
    m_int_configs[CONFIG_CHAT_SAY_LEVEL_REQ]                    = 1;
    m_bool_configs[CONFIG_ALLOW_PLAYER_COMMANDS]                = true;
    m_int_configs[CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION]      = 14;

    if (c_05_chat_settings)                                       
    {
        sLog.outString("Loading chat settings...");
        barGoLink bar(c_05_chat_settings->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_05_chat_settings->Fetch();

            if (fields[0].GetString() == "ChatFlood.MessageCount")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHATFLOOD_MESSAGE_COUNT])
                    m_int_configs[CONFIG_CHATFLOOD_MESSAGE_COUNT] = fields[1].GetUInt32();

            if (fields[0].GetString() == "ChatFlood.MessageDelay")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHATFLOOD_MESSAGE_DELAY])
                    m_int_configs[CONFIG_CHATFLOOD_MESSAGE_DELAY] = fields[1].GetUInt32();

            if (fields[0].GetString() == "ChatFlood.MuteTime")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHATFLOOD_MUTE_TIME])
                    m_int_configs[CONFIG_CHATFLOOD_MUTE_TIME] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Channel.RestrictedLfg")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_RESTRICTED_LFG_CHANNEL] = false;

            if (fields[0].GetString() == "Channel.SilentlyGMJoin")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL] = true;

            if (fields[0].GetString() == "ChatFakeMessagePreventing")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_CHAT_FAKE_MESSAGE_PREVENTING] = true;

            if (fields[0].GetString() == "ChatStrictLinkChecking.Severity")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY])
                    m_int_configs[CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY] = fields[1].GetUInt32();

            if (fields[0].GetString() == "ChatStrictLinkChecking.Kick")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHAT_STRICT_LINK_CHECKING_KICK])
                    m_int_configs[CONFIG_CHAT_STRICT_LINK_CHECKING_KICK] = fields[1].GetUInt32();

            if (fields[0].GetString() == "ChatLevelReq.Channel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHAT_CHANNEL_LEVEL_REQ])
                    m_int_configs[CONFIG_CHAT_CHANNEL_LEVEL_REQ] = fields[1].GetUInt32();

            if (fields[0].GetString() == "ChatLevelReq.Whisper")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHAT_WHISPER_LEVEL_REQ])
                    m_int_configs[CONFIG_CHAT_WHISPER_LEVEL_REQ] = fields[1].GetUInt32();

            if (fields[0].GetString() == "ChatLevelReq.Say")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHAT_SAY_LEVEL_REQ])
                    m_int_configs[CONFIG_CHAT_SAY_LEVEL_REQ] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AllowPlayerCommands")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_PLAYER_COMMANDS] = false;

            if (fields[0].GetString() == "PreserveCustomChannels")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_PRESERVE_CUSTOM_CHANNELS] = false;

            if (fields[0].GetString() == "PreserveCustomChannelDuration")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION])
                    m_int_configs[CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION] = fields[1].GetUInt32();

            ++count;
        }
        while (c_05_chat_settings->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u chat settings", count);
    }                                                               

    sLog.outConfig(" ~~~~~~~~~~~~~~~== Chat Settings ==~~~~~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("AllowPlayerCommands is set to -------------------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_PLAYER_COMMANDS]));
    sLog.outConfig("Channel.RestrictedLfg is set to ------------------------ %s", sc.ToString(m_bool_configs[CONFIG_RESTRICTED_LFG_CHANNEL]));
    sLog.outConfig("Channel.SilentlyGMJoin is set to ----------------------- %s", sc.ToString(m_bool_configs[CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL]));
    sLog.outConfig("ChatFakeMessagePreventing is set to -------------------- %s", sc.ToString(m_bool_configs[CONFIG_CHAT_FAKE_MESSAGE_PREVENTING]));
    sLog.outConfig("ChatFlood.MessageCount is set to ----------------------- %u", m_int_configs[CONFIG_CHATFLOOD_MESSAGE_COUNT]);
    sLog.outConfig("ChatFlood.MessageDelay is set to ----------------------- %u", m_int_configs[CONFIG_CHATFLOOD_MESSAGE_DELAY]);
    sLog.outConfig("ChatFlood.MuteTime is set to --------------------------- %u", m_int_configs[CONFIG_CHATFLOOD_MUTE_TIME]);
    sLog.outConfig("ChatLevelReq.Channel is set to ------------------------- %u", m_int_configs[CONFIG_CHAT_CHANNEL_LEVEL_REQ]);
    sLog.outConfig("ChatLevelReq.Say is set to ----------------------------- %u", m_int_configs[CONFIG_CHAT_SAY_LEVEL_REQ]);
    sLog.outConfig("ChatLevelReq.Whisper is set to ------------------------- %u", m_int_configs[CONFIG_CHAT_WHISPER_LEVEL_REQ]);
    sLog.outConfig("ChatStrictLinkChecking.Kick is set to ------------------ %u", m_int_configs[CONFIG_CHAT_STRICT_LINK_CHECKING_KICK]);
    sLog.outConfig("ChatStrictLinkChecking.Severity is set to -------------- %u", m_int_configs[CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY]);

    /// - gamemaster configs begin
    m_int_configs[CONFIG_GM_LOGIN_STATE]                = 2;
    m_int_configs[CONFIG_GM_VISIBLE_STATE]              = 2;
    m_int_configs[CONFIG_GM_CHAT]                       = 2;
    m_int_configs[CONFIG_GM_WHISPERING_TO]              = 2;
    m_int_configs[CONFIG_GM_LEVEL_IN_GM_LIST]           = SEC_ADMINISTRATOR;
    m_int_configs[CONFIG_GM_LEVEL_IN_WHO_LIST]          = SEC_ADMINISTRATOR;
    m_bool_configs[CONFIG_GM_LOG_TRADE]                 = false;
    m_int_configs[CONFIG_START_GM_LEVEL]                = 1;
    m_bool_configs[CONFIG_ALLOW_GM_GROUP]               = false;
    m_bool_configs[CONFIG_ALLOW_GM_FRIEND]              = false;
    m_bool_configs[CONFIG_GM_LOWER_SECURITY]            = false;
    m_bool_configs[CONFIG_GM_ALLOW_ACHIEVEMENT_GAINS]   = true;
    m_float_configs[CONFIG_CHANCE_OF_GM_SURVEY]         = 50.0f;

    if (c_06_gamemaster_settings)                                                    
    {
        sLog.outString("Loading gamemaster settings...");
        barGoLink bar(c_06_gamemaster_settings->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_06_gamemaster_settings->Fetch();

            if (fields[0].GetString() == "GM.LoginState")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_GM_LOGIN_STATE])
                    m_int_configs[CONFIG_GM_LOGIN_STATE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "GM.Visible")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_GM_VISIBLE_STATE])
                    m_int_configs[CONFIG_GM_VISIBLE_STATE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "GM.Chat")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_GM_CHAT])
                    m_int_configs[CONFIG_GM_CHAT] = fields[1].GetUInt32();

            if (fields[0].GetString() == "GM.WhisperingTo")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_GM_WHISPERING_TO])
                    m_int_configs[CONFIG_GM_WHISPERING_TO] = fields[1].GetUInt32();

            if (fields[0].GetString() == "GM.InGMList.Level")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_GM_LEVEL_IN_GM_LIST])
                    m_int_configs[CONFIG_GM_LEVEL_IN_GM_LIST] = fields[1].GetUInt32();

            if (fields[0].GetString() == "GM.InWhoList.Level")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_GM_LEVEL_IN_WHO_LIST])
                    m_int_configs[CONFIG_GM_LEVEL_IN_WHO_LIST] = fields[1].GetUInt32();

            if (fields[0].GetString() == "GM.LogTrade")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_GM_LOG_TRADE] = true;

            if (fields[0].GetString() == "GM.StartLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_START_GM_LEVEL])
                    m_int_configs[CONFIG_START_GM_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "GM.AllowInvite")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_GM_GROUP] = true;

            if (fields[0].GetString() == "GM.AllowFriend")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_GM_FRIEND] = true;

            if (fields[0].GetString() == "GM.LowerSecurity")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_GM_LOWER_SECURITY] = true;

            if (fields[0].GetString() == "GM.AllowAchievementGain")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_GM_ALLOW_ACHIEVEMENT_GAINS] = false;

            if (fields[0].GetString() == "GM.TicketSystem.ChanceOfGMSurvey")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_CHANCE_OF_GM_SURVEY])
                    m_float_configs[CONFIG_CHANCE_OF_GM_SURVEY] = fields[1].GetFloat();

            ++count;
        }
        while (c_06_gamemaster_settings->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u gamemaster settings", count);
    }                                                                     

    if (m_int_configs[CONFIG_START_GM_LEVEL] < m_int_configs[CONFIG_START_PLAYER_LEVEL])
    {
        sLog.outError("GM.StartLevel (%u) must be in range StartPlayerLevel(%u)..%u. Set to %u.", 
            m_int_configs[CONFIG_START_GM_LEVEL], m_int_configs[CONFIG_START_PLAYER_LEVEL], MAX_LEVEL, m_int_configs[CONFIG_START_PLAYER_LEVEL]);
        m_int_configs[CONFIG_START_GM_LEVEL] = m_int_configs[CONFIG_START_PLAYER_LEVEL];
    }
    else if (m_int_configs[CONFIG_START_GM_LEVEL] > MAX_LEVEL)
    {
        sLog.outError("GM.StartLevel (%u) must be in range 1..%u. Set to %u.", m_int_configs[CONFIG_START_GM_LEVEL], MAX_LEVEL, MAX_LEVEL);
        m_int_configs[CONFIG_START_GM_LEVEL] = MAX_LEVEL;
    }

    sLog.outConfig(" ~~~~~~~~~~~~== GameMaster Settings ==~~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("GM.AllowAchievementGain is set to ---------------------- %s", sc.ToString(m_bool_configs[CONFIG_GM_ALLOW_ACHIEVEMENT_GAINS]));
    sLog.outConfig("GM.AllowFriend is set to ------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_GM_FRIEND]));
    sLog.outConfig("GM.AllowInvite is set to ------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_GM_GROUP]));
    sLog.outConfig("GM.Chat is set to -------------------------------------- %u", m_int_configs[CONFIG_GM_CHAT]);
    sLog.outConfig("GM.InGMList.Level is set to ---------------------------- %u", m_int_configs[CONFIG_GM_LEVEL_IN_GM_LIST]);
    sLog.outConfig("GM.InWhoList.Level is set to --------------------------- %u", m_int_configs[CONFIG_GM_LEVEL_IN_WHO_LIST]);
    sLog.outConfig("GM.LoginState is set to -------------------------------- %u", m_int_configs[CONFIG_GM_LOGIN_STATE]);
    sLog.outConfig("GM.LogTrade is set to ---------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_GM_LOG_TRADE]));
    sLog.outConfig("GM.LowerSecurity is set to ----------------------------- %s", sc.ToString(m_bool_configs[CONFIG_GM_LOWER_SECURITY]));
    sLog.outConfig("GM.StartLevel is set to -------------------------------- %u", m_int_configs[CONFIG_START_GM_LEVEL]);
    sLog.outConfig("GM.TicketSystem.ChanceOfGMSurvey is set to ------------- %f", m_float_configs[CONFIG_CHANCE_OF_GM_SURVEY]);
    sLog.outConfig("GM.Visible is set to ----------------------------------- %u", m_int_configs[CONFIG_GM_VISIBLE_STATE]);
    sLog.outConfig("GM.WhisperingTo is set to ------------------------------ %u", m_int_configs[CONFIG_GM_WHISPERING_TO]);

    /// - visibility configs begin
    m_int_configs[CONFIG_GROUP_VISIBILITY]  = 1;
    m_MaxVisibleDistanceOnContinents        = DEFAULT_VISIBILITY_DISTANCE;
    m_MaxVisibleDistanceInInstances         = DEFAULT_VISIBILITY_INSTANCE;
    m_MaxVisibleDistanceInBGArenas          = DEFAULT_VISIBILITY_BGARENAS;
    m_visibility_notify_periodOnContinents  = DEFAULT_VISIBILITY_NOTIFY_PERIOD;
    m_visibility_notify_periodInInstances   = DEFAULT_VISIBILITY_NOTIFY_PERIOD;
    m_visibility_notify_periodInBGArenas    = DEFAULT_VISIBILITY_NOTIFY_PERIOD;

    if (c_07_visibility)                                                 
    {
        sLog.outString("Loading visibility settings...");
        barGoLink bar(c_07_visibility->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_07_visibility->Fetch();

            if (fields[0].GetString() == "Visibility.GroupMode")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_GROUP_VISIBILITY])
                    m_int_configs[CONFIG_GROUP_VISIBILITY] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Visibility.Distance.Continents")
                if (fields[1].GetFloat() != m_MaxVisibleDistanceOnContinents)
                    m_MaxVisibleDistanceOnContinents = fields[1].GetFloat();

            if (fields[0].GetString() == "Visibility.Distance.Instances")
                if (fields[1].GetFloat() != m_MaxVisibleDistanceInInstances)
                    m_MaxVisibleDistanceInInstances = fields[1].GetFloat();

            if (fields[0].GetString() == "Visibility.Distance.BGArenas")
                if (fields[1].GetFloat() != m_MaxVisibleDistanceInBGArenas)
                    m_MaxVisibleDistanceInBGArenas = fields[1].GetFloat();

            if (fields[0].GetString() == "Visibility.Notify.Period.OnContinents")
                if (fields[1].GetUInt32() != m_visibility_notify_periodOnContinents)
                    m_visibility_notify_periodOnContinents = fields[1].GetUInt32();

            if (fields[0].GetString() == "Visibility.Notify.Period.InInstances")
                if (fields[1].GetUInt32() != m_visibility_notify_periodInInstances)
                    m_visibility_notify_periodInInstances = fields[1].GetUInt32();

            if (fields[0].GetString() == "Visibility.Notify.Period.InBGArenas")
                if (fields[1].GetUInt32() != m_visibility_notify_periodInBGArenas)
                    m_visibility_notify_periodInBGArenas = fields[1].GetUInt32();

            ++count;
        }
        while (c_07_visibility->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u visibility settings", count);
    }                                                                  

    //visibility on continents
    if (m_MaxVisibleDistanceOnContinents < 45 * sWorld.getRate(RATE_CREATURE_AGGRO))
    {
        sLog.outError("Visibility.Distance.Continents can't be less max aggro radius %f", 45 * sWorld.getRate(RATE_CREATURE_AGGRO));
        m_MaxVisibleDistanceOnContinents = 45 * sWorld.getRate(RATE_CREATURE_AGGRO);
    }
    else if (m_MaxVisibleDistanceOnContinents > MAX_VISIBILITY_DISTANCE)
    {
        sLog.outError("Visibility.Distance.Continents can't be greater %f",MAX_VISIBILITY_DISTANCE);
        m_MaxVisibleDistanceOnContinents = MAX_VISIBILITY_DISTANCE;
    }
    if (m_MaxVisibleDistanceInInstances < 45*sWorld.getRate(RATE_CREATURE_AGGRO))
    {
        sLog.outError("Visibility.Distance.Instances can't be less max aggro radius %f", 45 * sWorld.getRate(RATE_CREATURE_AGGRO));
        m_MaxVisibleDistanceInInstances = 45 * sWorld.getRate(RATE_CREATURE_AGGRO);
    }
    else if (m_MaxVisibleDistanceInInstances > MAX_VISIBILITY_DISTANCE)
    {
        sLog.outError("Visibility.Distance.Instances can't be greater %f",MAX_VISIBILITY_DISTANCE);
        m_MaxVisibleDistanceInInstances = MAX_VISIBILITY_DISTANCE;
    }
    if (m_MaxVisibleDistanceInBGArenas < 45*sWorld.getRate(RATE_CREATURE_AGGRO))
    {
        sLog.outError("Visibility.Distance.BGArenas can't be less max aggro radius %f", 45 * sWorld.getRate(RATE_CREATURE_AGGRO));
        m_MaxVisibleDistanceInBGArenas = 45 * sWorld.getRate(RATE_CREATURE_AGGRO);
    }
    else if (m_MaxVisibleDistanceInBGArenas > MAX_VISIBILITY_DISTANCE)
    {
        sLog.outError("Visibility.Distance.BGArenas can't be greater %f",MAX_VISIBILITY_DISTANCE);
        m_MaxVisibleDistanceInBGArenas = MAX_VISIBILITY_DISTANCE;
    }

    sLog.outConfig(" ~~~~~~~~~~~~== Visibility Settings ==~~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("Visibility.Distance.BGArenas is set to ----------------- %f", m_MaxVisibleDistanceInBGArenas);
    sLog.outConfig("Visibility.Distance.Continents is set to --------------- %f", m_MaxVisibleDistanceOnContinents);
    sLog.outConfig("Visibility.Distance.Instances is set to ---------------- %f", m_MaxVisibleDistanceInInstances);
    sLog.outConfig("Visibility.GroupMode is set to ------------------------- %u", m_int_configs[CONFIG_GROUP_VISIBILITY]);
    sLog.outConfig("Visibility.Notify.Period.InBGArenas is set to ---------- %u", m_visibility_notify_periodInBGArenas);
    sLog.outConfig("Visibility.Notify.Period.InInstances is set to --------- %u", m_visibility_notify_periodInInstances);
    sLog.outConfig("Visibility.Notify.Period.OnContinents is set to -------- %u", m_visibility_notify_periodOnContinents);

    /// - server rates configs begin
    rate_values[RATE_HEALTH]                                        = 1.0f;  // get health rate
    rate_values[RATE_POWER_MANA]                                    = 1.0f;  // get mana rate
    rate_values[RATE_POWER_RAGE_INCOME]                             = 1.0f;  // get rage income
    m_float_configs[CONFIG_SIGHT_MONSTER]                           = 50.0f;
    m_float_configs[CONFIG_SIGHT_GUARDER]                           = 50.0f;
    m_int_configs[CONFIG_SKILL_CHANCE_ORANGE]                       = 100;
    m_int_configs[CONFIG_SKILL_CHANCE_YELLOW]                       = 75;
    m_int_configs[CONFIG_SKILL_CHANCE_GREEN]                        = 25;
    m_int_configs[CONFIG_SKILL_CHANCE_GREY]                         = 0;
    m_int_configs[CONFIG_SKILL_CHANCE_MINING_STEPS]                 = 0;
    m_int_configs[CONFIG_SKILL_CHANCE_SKINNING_STEPS]               = 0;
    m_int_configs[CONFIG_SKILL_GAIN_CRAFTING]                       = 1;
    m_int_configs[CONFIG_SKILL_GAIN_DEFENSE]                        = 1;
    m_int_configs[CONFIG_SKILL_GAIN_GATHERING]                      = 1;
    m_int_configs[CONFIG_SKILL_GAIN_WEAPON]                         = 1;
    m_float_configs[CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS]  = 30.0f;
    m_float_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS]       = 10.0f;
    m_int_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY]          = 1500;
    m_int_configs[CONFIG_CREATURE_FAMILY_FLEE_DELAY]                = 7000;
    m_int_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF]                     = 3;
    m_int_configs[CONFIG_CORPSE_DECAY_NORMAL]                       = 60;
    m_int_configs[CONFIG_CORPSE_DECAY_RARE]                         = 300;
    m_int_configs[CONFIG_CORPSE_DECAY_ELITE]                        = 300;
    m_int_configs[CONFIG_CORPSE_DECAY_RAREELITE]                    = 300;
    m_int_configs[CONFIG_CORPSE_DECAY_WORLDBOSS]                    = 3600;
    m_int_configs[CONFIG_DEATH_SICKNESS_LEVEL]                      = 11;
    m_bool_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP]           = true;
    m_bool_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE]           = false;
    m_bool_configs[CONFIG_DEATH_BONES_WORLD]                        = true;
    m_bool_configs[CONFIG_DEATH_BONES_BG_OR_ARENA]                  = true;
    m_bool_configs[CONFIG_DIE_COMMAND_MODE]                         = true;
    m_float_configs[CONFIG_THREAT_RADIUS]                           = 60.0f;
    m_float_configs[CONFIG_LISTEN_RANGE_SAY]                        = 40.0f;
    m_float_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE]                  = 40.0f;
    m_float_configs[CONFIG_LISTEN_RANGE_YELL]                       = 300.0f;
    rate_values[RATE_POWER_RAGE_LOSS]                               = 1.0f;
    rate_values[RATE_POWER_RUNICPOWER_INCOME]                       = 1.0f;
    rate_values[RATE_POWER_RUNICPOWER_LOSS]                         = 1.0f;
    rate_values[RATE_POWER_FOCUS]                                   = 1.0f;
    rate_values[RATE_SKILL_DISCOVERY]                               = 1.0f;
    rate_values[RATE_DROP_ITEM_POOR]                                = 1.0f;
    rate_values[RATE_DROP_ITEM_NORMAL]                              = 1.0f;
    rate_values[RATE_DROP_ITEM_UNCOMMON]                            = 1.0f;
    rate_values[RATE_DROP_ITEM_RARE]                                = 1.0f;
    rate_values[RATE_DROP_ITEM_EPIC]                                = 1.0f;
    rate_values[RATE_DROP_ITEM_LEGENDARY]                           = 1.0f;
    rate_values[RATE_DROP_ITEM_ARTIFACT]                            = 1.0f;
    rate_values[RATE_DROP_ITEM_REFERENCED]                          = 1.0f;
    rate_values[RATE_DROP_ITEM_REFERENCED_AMOUNT]                   = 1.0f;
    rate_values[RATE_DROP_MONEY]                                    = 1.0f;
    rate_values[RATE_XP_KILL]                                       = 1.0f;
    rate_values[RATE_XP_QUEST]                                      = 1.0f;
    rate_values[RATE_XP_EXPLORE]                                    = 1.0f;
    rate_values[RATE_REPAIRCOST]                                    = 1.0f;
    rate_values[RATE_REPUTATION_GAIN]                               = 1.0f;
    rate_values[RATE_REPUTATION_LOWLEVEL_KILL]                      = 1.0f;
    rate_values[RATE_REPUTATION_LOWLEVEL_QUEST]                     = 1.0f;
    rate_values[RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS]             = 0.1f;
    rate_values[RATE_CREATURE_NORMAL_DAMAGE]                        = 1.0f;
    rate_values[RATE_CREATURE_ELITE_ELITE_DAMAGE]                   = 1.0f;
    rate_values[RATE_CREATURE_ELITE_RAREELITE_DAMAGE]               = 1.0f;
    rate_values[RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE]               = 1.0f;
    rate_values[RATE_CREATURE_ELITE_RARE_DAMAGE]                    = 1.0f;
    rate_values[RATE_CREATURE_NORMAL_HP]                            = 1.0f;
    rate_values[RATE_CREATURE_ELITE_ELITE_HP]                       = 1.0f;
    rate_values[RATE_CREATURE_ELITE_RAREELITE_HP]                   = 1.0f;
    rate_values[RATE_CREATURE_ELITE_WORLDBOSS_HP]                   = 1.0f;
    rate_values[RATE_CREATURE_ELITE_RARE_HP]                        = 1.0f;
    rate_values[RATE_CREATURE_NORMAL_SPELLDAMAGE]                   = 1.0f;
    rate_values[RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE]              = 1.0f;
    rate_values[RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE]          = 1.0f;
    rate_values[RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE]          = 1.0f;
    rate_values[RATE_CREATURE_ELITE_RARE_SPELLDAMAGE]               = 1.0f;
    rate_values[RATE_CREATURE_AGGRO]                                = 1.0f;
    rate_values[RATE_REST_INGAME]                                   = 1.0f;
    rate_values[RATE_REST_OFFLINE_IN_TAVERN_OR_CITY]                = 1.0f;
    rate_values[RATE_REST_OFFLINE_IN_WILDERNESS]                    = 1.0f;
    rate_values[RATE_DAMAGE_FALL]                                   = 1.0f;
    rate_values[RATE_AUCTION_TIME]                                  = 1.0f;
    rate_values[RATE_AUCTION_DEPOSIT]                               = 1.0f;
    rate_values[RATE_AUCTION_CUT]                                   = 1.0f;
    rate_values[RATE_HONOR]                                         = 1.0f;
    rate_values[RATE_MINING_AMOUNT]                                 = 1.0f;
    rate_values[RATE_MINING_NEXT]                                   = 1.0f;
    rate_values[RATE_INSTANCE_RESET_TIME]                           = 1.0f;
    rate_values[RATE_TALENT]                                        = 1.0f;
    rate_values[RATE_MOVESPEED]                                     = 1.0f;
    rate_values[RATE_CORPSE_DECAY_LOOTED]                           = 0.5f;
    rate_values[RATE_TARGET_POS_RECALCULATION_RANGE]                = 1.5f;
    rate_values[RATE_DURABILITY_LOSS_ON_DEATH]                      = 10.0f;
    rate_values[RATE_DURABILITY_LOSS_DAMAGE]                        = 0.5f;
    rate_values[RATE_DURABILITY_LOSS_ABSORB]                        = 0.5f;
    rate_values[RATE_DURABILITY_LOSS_PARRY]                         = 0.05f;
    rate_values[RATE_DURABILITY_LOSS_BLOCK]                         = 0.05f;
    m_bool_configs[CONFIG_DURABILITY_LOSS_IN_PVP]                   = false;

    if (c_08_server_rates)                                                     
    {
        sLog.outString("Loading server rates...");
        barGoLink bar(c_08_server_rates->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_08_server_rates->Fetch();

            if (fields[0].GetString() == "Rate.Health")
                if (fields[1].GetFloat() != rate_values[RATE_HEALTH])
                    rate_values[RATE_HEALTH] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Mana")
                if (fields[1].GetFloat() != rate_values[RATE_POWER_MANA])
                    rate_values[RATE_POWER_MANA] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Rage.Income")
                if (fields[1].GetFloat() != rate_values[RATE_POWER_RAGE_INCOME])
                    rate_values[RATE_POWER_RAGE_INCOME] = fields[1].GetFloat();

            if (fields[0].GetString() == "MonsterSight")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_SIGHT_MONSTER])
                    m_float_configs[CONFIG_SIGHT_MONSTER] = fields[1].GetFloat();

            if (fields[0].GetString() == "GuarderSight")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_SIGHT_GUARDER])
                    m_float_configs[CONFIG_SIGHT_GUARDER] = fields[1].GetFloat();

            if (fields[0].GetString() == "SkillChance.Orange")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKILL_CHANCE_ORANGE])
                    m_int_configs[CONFIG_SKILL_CHANCE_ORANGE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkillChance.Yellow")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKILL_CHANCE_YELLOW])
                    m_int_configs[CONFIG_SKILL_CHANCE_YELLOW] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkillChance.Green")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKILL_CHANCE_GREEN])
                    m_int_configs[CONFIG_SKILL_CHANCE_GREEN] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkillChance.Grey")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKILL_CHANCE_GREY])
                    m_int_configs[CONFIG_SKILL_CHANCE_GREY] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkillChance.MiningSteps")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKILL_CHANCE_MINING_STEPS])
                    m_int_configs[CONFIG_SKILL_CHANCE_MINING_STEPS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkillChance.SkinningSteps")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKILL_CHANCE_SKINNING_STEPS])
                    m_int_configs[CONFIG_SKILL_CHANCE_SKINNING_STEPS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkillGain.Crafting")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKILL_GAIN_CRAFTING])
                    m_int_configs[CONFIG_SKILL_GAIN_CRAFTING] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkillGain.Defense")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKILL_GAIN_DEFENSE])
                    m_int_configs[CONFIG_SKILL_GAIN_DEFENSE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkillGain.Gathering")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKILL_GAIN_GATHERING])
                    m_int_configs[CONFIG_SKILL_GAIN_GATHERING] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SkillGain.Weapon")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SKILL_GAIN_WEAPON])
                    m_int_configs[CONFIG_SKILL_GAIN_WEAPON] = fields[1].GetUInt32();

            if (fields[0].GetString() == "CreatureFamilyFleeAssistanceRadius")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS])
                    m_float_configs[CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS] = fields[1].GetFloat();

            if (fields[0].GetString() == "CreatureFamilyAssistanceRadius")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS])
                    m_float_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS] = fields[1].GetFloat();

            if (fields[0].GetString() == "CreatureFamilyAssistanceDelay")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY])
                    m_int_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY] = fields[1].GetUInt32();

            if (fields[0].GetString() == "CreatureFamilyFleeDelay")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CREATURE_FAMILY_FLEE_DELAY])
                    m_int_configs[CONFIG_CREATURE_FAMILY_FLEE_DELAY] = fields[1].GetUInt32();

            if (fields[0].GetString() == "WorldBossLevelDiff")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF])
                    m_int_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Corpse.Decay.NORMAL")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CORPSE_DECAY_NORMAL])
                    m_int_configs[CONFIG_CORPSE_DECAY_NORMAL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Corpse.Decay.RARE")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CORPSE_DECAY_RARE])
                    m_int_configs[CONFIG_CORPSE_DECAY_RARE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Corpse.Decay.ELITE")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CORPSE_DECAY_ELITE])
                    m_int_configs[CONFIG_CORPSE_DECAY_ELITE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Corpse.Decay.RAREELITE")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CORPSE_DECAY_RAREELITE])
                    m_int_configs[CONFIG_CORPSE_DECAY_RAREELITE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Corpse.Decay.WORLDBOSS")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CORPSE_DECAY_WORLDBOSS])
                    m_int_configs[CONFIG_CORPSE_DECAY_WORLDBOSS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Death.SicknessLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_DEATH_SICKNESS_LEVEL])
                    m_int_configs[CONFIG_DEATH_SICKNESS_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Death.CorpseReclaimDelay.PvP")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP] = false;

            if (fields[0].GetString() == "Death.CorpseReclaimDelay.PvE")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE] = true;

            if (fields[0].GetString() == "Death.Bones.World")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_DEATH_BONES_WORLD] = false;

            if (fields[0].GetString() == "Death.Bones.BattlegroundOrArena")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_DEATH_BONES_BG_OR_ARENA] = false;

            if (fields[0].GetString() == "Die.Command.Mode")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_DIE_COMMAND_MODE] = false;

            if (fields[0].GetString() == "ThreatRadius")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_THREAT_RADIUS])
                    m_float_configs[CONFIG_THREAT_RADIUS] = fields[1].GetFloat();

            if (fields[0].GetString() == "ListenRange.Say")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_LISTEN_RANGE_SAY])
                    m_float_configs[CONFIG_LISTEN_RANGE_SAY] = fields[1].GetFloat();

            if (fields[0].GetString() == "ListenRange.TextEmote")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE])
                    m_float_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE] = fields[1].GetFloat();

            if (fields[0].GetString() == "ListenRange.Yell")
                if (fields[1].GetFloat() != m_float_configs[CONFIG_LISTEN_RANGE_YELL])
                    m_float_configs[CONFIG_LISTEN_RANGE_YELL] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Rage.Loss")
                if (fields[1].GetFloat() != rate_values[RATE_POWER_RAGE_LOSS])
                    rate_values[RATE_POWER_RAGE_LOSS] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.RunicPower.Income")
                if (fields[1].GetFloat() != rate_values[RATE_POWER_RUNICPOWER_INCOME])
                    rate_values[RATE_POWER_RUNICPOWER_INCOME] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.RunicPower.Loss")
                if (fields[1].GetFloat() != rate_values[RATE_POWER_RUNICPOWER_LOSS])
                    rate_values[RATE_POWER_RUNICPOWER_LOSS] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Focus")
                if (fields[1].GetFloat() != rate_values[RATE_POWER_FOCUS])
                    rate_values[RATE_POWER_FOCUS] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Energy")
                if (fields[1].GetFloat() != rate_values[RATE_POWER_ENERGY])
                    rate_values[RATE_POWER_ENERGY] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Skill.Discovery")
                if (fields[1].GetFloat() != rate_values[RATE_SKILL_DISCOVERY])
                    rate_values[RATE_SKILL_DISCOVERY] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Drop.Item.Poor")
                if (fields[1].GetFloat() != rate_values[RATE_DROP_ITEM_POOR])
                    rate_values[RATE_DROP_ITEM_POOR] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Drop.Item.Normal")
                if (fields[1].GetFloat() != rate_values[RATE_DROP_ITEM_NORMAL])
                    rate_values[RATE_DROP_ITEM_NORMAL] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Drop.Item.Uncommon")
                if (fields[1].GetFloat() != rate_values[RATE_DROP_ITEM_UNCOMMON])
                    rate_values[RATE_DROP_ITEM_UNCOMMON] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Drop.Item.Rare")
                if (fields[1].GetFloat() != rate_values[RATE_DROP_ITEM_RARE])
                    rate_values[RATE_DROP_ITEM_RARE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Drop.Item.Epic")
                if (fields[1].GetFloat() != rate_values[RATE_DROP_ITEM_EPIC])
                    rate_values[RATE_DROP_ITEM_EPIC] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Drop.Item.Legendary")
                if (fields[1].GetFloat() != rate_values[RATE_DROP_ITEM_LEGENDARY])
                    rate_values[RATE_DROP_ITEM_LEGENDARY] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Drop.Item.Artifact")
                if (fields[1].GetFloat() != rate_values[RATE_DROP_ITEM_ARTIFACT])
                    rate_values[RATE_DROP_ITEM_ARTIFACT] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Drop.Item.Referenced")
                if (fields[1].GetFloat() != rate_values[RATE_DROP_ITEM_REFERENCED])
                    rate_values[RATE_DROP_ITEM_REFERENCED] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Drop.Item.ReferencedAmount")
                if (fields[1].GetFloat() != rate_values[RATE_DROP_ITEM_REFERENCED_AMOUNT])
                    rate_values[RATE_DROP_ITEM_REFERENCED_AMOUNT] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Drop.Money")
                if (fields[1].GetFloat() != rate_values[RATE_DROP_MONEY])
                    rate_values[RATE_DROP_MONEY] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.XP.Kill")
                if (fields[1].GetFloat() != rate_values[RATE_XP_KILL])
                    rate_values[RATE_XP_KILL] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.XP.Quest")
                if (fields[1].GetFloat() != rate_values[RATE_XP_QUEST])
                    rate_values[RATE_XP_QUEST] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.XP.Explore")
                if (fields[1].GetFloat() != rate_values[RATE_XP_EXPLORE])
                    rate_values[RATE_XP_EXPLORE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.RepairCost")
                if (fields[1].GetFloat() != rate_values[RATE_REPAIRCOST])
                    rate_values[RATE_REPAIRCOST] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Reputation.Gain")
                if (fields[1].GetFloat() != rate_values[RATE_REPUTATION_GAIN])
                    rate_values[RATE_REPUTATION_GAIN] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Reputation.LowLevel.Kill")
                if (fields[1].GetFloat() != rate_values[RATE_REPUTATION_LOWLEVEL_KILL])
                    rate_values[RATE_REPUTATION_LOWLEVEL_KILL] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Reputation.LowLevel.Quest")
                if (fields[1].GetFloat() != rate_values[RATE_REPUTATION_LOWLEVEL_QUEST])
                    rate_values[RATE_REPUTATION_LOWLEVEL_QUEST] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Reputation.RecruitAFriendBonus")
                if (fields[1].GetFloat() != rate_values[RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS])
                    rate_values[RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Normal.Damage")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_NORMAL_DAMAGE])
                    rate_values[RATE_CREATURE_NORMAL_DAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.Elite.Damage")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_ELITE_DAMAGE])
                    rate_values[RATE_CREATURE_ELITE_ELITE_DAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.RAREELITE.Damage")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_RAREELITE_DAMAGE])
                    rate_values[RATE_CREATURE_ELITE_RAREELITE_DAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.WORLDBOSS.Damage")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE])
                    rate_values[RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.RARE.Damage")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_RARE_DAMAGE])
                    rate_values[RATE_CREATURE_ELITE_RARE_DAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Normal.HP")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_NORMAL_HP])
                    rate_values[RATE_CREATURE_NORMAL_HP] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.Elite.HP")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_ELITE_HP])
                    rate_values[RATE_CREATURE_ELITE_ELITE_HP] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.RAREELITE.HP")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_RAREELITE_HP])
                    rate_values[RATE_CREATURE_ELITE_RAREELITE_HP] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.WORLDBOSS.HP")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_WORLDBOSS_HP])
                    rate_values[RATE_CREATURE_ELITE_WORLDBOSS_HP] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.RARE.HP")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_RARE_HP])
                    rate_values[RATE_CREATURE_ELITE_RARE_HP] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Normal.SpellDamage")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_NORMAL_SPELLDAMAGE])
                    rate_values[RATE_CREATURE_NORMAL_SPELLDAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.Elite.SpellDamage")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE])
                    rate_values[RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.RAREELITE.SpellDamage")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE])
                    rate_values[RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.WORLDBOSS.SpellDamage")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE])
                    rate_values[RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Elite.RARE.SpellDamage")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_ELITE_RARE_SPELLDAMAGE])
                    rate_values[RATE_CREATURE_ELITE_RARE_SPELLDAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Creature.Aggro")
                if (fields[1].GetFloat() != rate_values[RATE_CREATURE_AGGRO])
                    rate_values[RATE_CREATURE_AGGRO] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Rest.InGame")
                if (fields[1].GetFloat() != rate_values[RATE_REST_INGAME])
                    rate_values[RATE_REST_INGAME] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Rest.Offline.InTavernOrCity")
                if (fields[1].GetFloat() != rate_values[RATE_REST_OFFLINE_IN_TAVERN_OR_CITY])
                    rate_values[RATE_REST_OFFLINE_IN_TAVERN_OR_CITY] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Rest.Offline.InWilderness")
                if (fields[1].GetFloat() != rate_values[RATE_REST_OFFLINE_IN_WILDERNESS])
                    rate_values[RATE_REST_OFFLINE_IN_WILDERNESS] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Damage.Fall")
                if (fields[1].GetFloat() != rate_values[RATE_DAMAGE_FALL])
                    rate_values[RATE_DAMAGE_FALL] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Auction.Time")
                if (fields[1].GetFloat() != rate_values[RATE_AUCTION_TIME])
                    rate_values[RATE_AUCTION_TIME] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Auction.Deposit")
                if (fields[1].GetFloat() != rate_values[RATE_AUCTION_DEPOSIT])
                    rate_values[RATE_AUCTION_DEPOSIT] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Auction.Cut")
                if (fields[1].GetFloat() != rate_values[RATE_AUCTION_CUT])
                    rate_values[RATE_AUCTION_CUT] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Honor")
                if (fields[1].GetFloat() != rate_values[RATE_HONOR])
                    rate_values[RATE_HONOR] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Mining.Amount")
                if (fields[1].GetFloat() != rate_values[RATE_MINING_AMOUNT])
                    rate_values[RATE_MINING_AMOUNT] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Mining.Next")
                if (fields[1].GetFloat() != rate_values[RATE_MINING_NEXT])
                    rate_values[RATE_MINING_NEXT] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.InstanceResetTime")
                if (fields[1].GetFloat() != rate_values[RATE_INSTANCE_RESET_TIME])
                    rate_values[RATE_INSTANCE_RESET_TIME] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Talent")
                if (fields[1].GetFloat() != rate_values[RATE_TALENT])
                    rate_values[RATE_TALENT] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.MoveSpeed")
                if (fields[1].GetFloat() != rate_values[RATE_MOVESPEED])
                    rate_values[RATE_MOVESPEED] = fields[1].GetFloat();

            if (fields[0].GetString() == "Rate.Corpse.Decay.Looted")
                if (fields[1].GetFloat() != rate_values[RATE_CORPSE_DECAY_LOOTED])
                    rate_values[RATE_CORPSE_DECAY_LOOTED] = fields[1].GetFloat();

            if (fields[0].GetString() == "TargetPosRecalculateRange")
                if (fields[1].GetFloat() != rate_values[RATE_TARGET_POS_RECALCULATION_RANGE])
                    rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "DurabilityLoss.OnDeath")
                if (fields[1].GetFloat() != rate_values[RATE_DURABILITY_LOSS_ON_DEATH])
                    rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = fields[1].GetFloat();

            if (fields[0].GetString() == "DurabilityLossChance.Damage")
                if (fields[1].GetFloat() != rate_values[RATE_DURABILITY_LOSS_DAMAGE])
                    rate_values[RATE_DURABILITY_LOSS_DAMAGE] = fields[1].GetFloat();

            if (fields[0].GetString() == "DurabilityLossChance.Absorb")
                if (fields[1].GetFloat() != rate_values[RATE_DURABILITY_LOSS_ABSORB])
                    rate_values[RATE_DURABILITY_LOSS_ABSORB] = fields[1].GetFloat();

            if (fields[0].GetString() == "DurabilityLossChance.Parry")
                if (fields[1].GetFloat() != rate_values[RATE_DURABILITY_LOSS_PARRY])
                    rate_values[RATE_DURABILITY_LOSS_PARRY] = fields[1].GetFloat();

            if (fields[0].GetString() == "DurabilityLossChance.Block")
                if (fields[1].GetFloat() != rate_values[RATE_DURABILITY_LOSS_BLOCK])
                    rate_values[RATE_DURABILITY_LOSS_BLOCK] = fields[1].GetFloat();

            if (fields[0].GetString() == "DurabilityLoss.InPvP")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_DURABILITY_LOSS_IN_PVP] = true;

            ++count;
        }
        while (c_08_server_rates->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u server rates", count);
    }                                                                    

    if (rate_values[RATE_HEALTH] < 0)
    {
        sLog.outError("Rate.Health (%f) must be > 0. Using 1 instead.", rate_values[RATE_HEALTH]);
        rate_values[RATE_HEALTH] = 1.0f;
    }
    if (rate_values[RATE_POWER_MANA] < 0)
    {
        sLog.outError("Rate.Mana (%f) must be > 0. Using 1 instead.", rate_values[RATE_POWER_MANA]);
        rate_values[RATE_POWER_MANA] = 1.0f;
    }
    if (rate_values[RATE_POWER_RAGE_LOSS] < 0)
    {
        sLog.outError("Rate.Rage.Loss (%f) must be > 0. Using 1 instead.", rate_values[RATE_POWER_RAGE_LOSS]);
        rate_values[RATE_POWER_RAGE_LOSS] = 1.0f;
    }
    if (rate_values[RATE_POWER_RUNICPOWER_LOSS] < 0)
    {
        sLog.outError("Rate.RunicPower.Loss (%f) must be > 0. Using 1 instead.", rate_values[RATE_POWER_RUNICPOWER_LOSS]);
        rate_values[RATE_POWER_RUNICPOWER_LOSS] = 1.0f;
    }
    if (rate_values[RATE_REPAIRCOST] < 0.0f)
    {
        sLog.outError("Rate.RepairCost (%f) must be >=0. Using 0.0 instead.", rate_values[RATE_REPAIRCOST]);
        rate_values[RATE_REPAIRCOST] = 1.0f;
    }
    if (rate_values[RATE_TALENT] < 0.0f)
    {
        sLog.outError("Rate.Talent (%f) must be > 0. Using 1 instead.", rate_values[RATE_TALENT]);
        rate_values[RATE_TALENT] = 1.0f;
    }
    if (rate_values[RATE_MOVESPEED] < 0)
    {
        sLog.outError("Rate.MoveSpeed (%f) must be > 0. Using 1 instead.", rate_values[RATE_MOVESPEED]);
        rate_values[RATE_MOVESPEED] = 1.0f;
    }
    for (uint8 i = 0; i < MAX_MOVE_TYPE; ++i)
    {
        playerBaseMoveSpeed[i] = baseMoveSpeed[i] * rate_values[RATE_MOVESPEED];
    }
    if (rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] < CONTACT_DISTANCE)
    {
        sLog.outError("TargetPosRecalculateRange (%f) must be >= %f. Using %f instead.", rate_values[RATE_TARGET_POS_RECALCULATION_RANGE], CONTACT_DISTANCE, CONTACT_DISTANCE);
        rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = CONTACT_DISTANCE;
    }
    else if (rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] > NOMINAL_MELEE_RANGE)
    {
        sLog.outError("TargetPosRecalculateRange (%f) must be <= %f. Using %f instead.", rate_values[RATE_TARGET_POS_RECALCULATION_RANGE], NOMINAL_MELEE_RANGE,NOMINAL_MELEE_RANGE);
        rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = NOMINAL_MELEE_RANGE;
    }
    if (rate_values[RATE_DURABILITY_LOSS_ON_DEATH] < 0.0f)
    {
        sLog.outError("DurabilityLoss.OnDeath (%f) must be >=0. Using 0.0 instead.", rate_values[RATE_DURABILITY_LOSS_ON_DEATH]);
        rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = 10.0f;
    }
    else if (rate_values[RATE_DURABILITY_LOSS_ON_DEATH] > 100.0f)
    {
        sLog.outError("DurabilityLoss.OnDeath (%f) must be <= 100. Using 100.0 instead.", rate_values[RATE_DURABILITY_LOSS_ON_DEATH]);
        rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = 10.0f;
    }

    rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = rate_values[RATE_DURABILITY_LOSS_ON_DEATH] / 100.0f;

    if (rate_values[RATE_DURABILITY_LOSS_DAMAGE] < 0.0f)
    {
        sLog.outError("DurabilityLossChance.Damage (%f) must be >=0. Using 0.0 instead.", rate_values[RATE_DURABILITY_LOSS_DAMAGE]);
        rate_values[RATE_DURABILITY_LOSS_DAMAGE] = 0.5f;
    }
    if (rate_values[RATE_DURABILITY_LOSS_ABSORB] < 0.0f)
    {
        sLog.outError("DurabilityLossChance.Absorb (%f) must be >=0. Using 0.0 instead.", rate_values[RATE_DURABILITY_LOSS_ABSORB]);
        rate_values[RATE_DURABILITY_LOSS_ABSORB] = 0.5f;
    }
    if (rate_values[RATE_DURABILITY_LOSS_PARRY] < 0.0f)
    {
        sLog.outError("DurabilityLossChance.Parry (%f) must be >=0. Using 0.0 instead.", rate_values[RATE_DURABILITY_LOSS_PARRY]);
        rate_values[RATE_DURABILITY_LOSS_PARRY] = 0.05f;
    }
    if (rate_values[RATE_DURABILITY_LOSS_BLOCK] < 0.0f)
    {
        sLog.outError("DurabilityLossChance.Block (%f) must be >=0. Using 0.0 instead.", rate_values[RATE_DURABILITY_LOSS_BLOCK]);
        rate_values[RATE_DURABILITY_LOSS_BLOCK] = 0.5f;
    }

    sLog.outConfig(" ~~~~~~~~~~~== Server Rate Settings ==~~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("Corpse.Decay.ELITE is set to --------------------------- %u", m_int_configs[CONFIG_CORPSE_DECAY_ELITE]);
    sLog.outConfig("Corpse.Decay.NORMAL is set to -------------------------- %u", m_int_configs[CONFIG_CORPSE_DECAY_NORMAL]);
    sLog.outConfig("Corpse.Decay.RARE is set to ---------------------------- %u", m_int_configs[CONFIG_CORPSE_DECAY_RARE]);
    sLog.outConfig("Corpse.Decay.RAREELITE is set to ----------------------- %u", m_int_configs[CONFIG_CORPSE_DECAY_RAREELITE]);
    sLog.outConfig("Corpse.Decay.WORLDBOSS is set to ----------------------- %u", m_int_configs[CONFIG_CORPSE_DECAY_WORLDBOSS]);
    sLog.outConfig("CreatureFamilyAssistanceDelay is set to ---------------- %u", m_int_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_DELAY]);
    sLog.outConfig("CreatureFamilyAssistanceRadius is set to --------------- %f", m_float_configs[CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS]);
    sLog.outConfig("CreatureFamilyFleeAssistanceRadius is set to ----------- %f", m_float_configs[CONFIG_CREATURE_FAMILY_FLEE_ASSISTANCE_RADIUS]);
    sLog.outConfig("CreatureFamilyFleeDelay is set to ---------------------- %u", m_int_configs[CONFIG_CREATURE_FAMILY_FLEE_DELAY]);
    sLog.outConfig("Death.Bones.BattlegroundOrArena is set to -------------- %s", sc.ToString(m_bool_configs[CONFIG_DEATH_BONES_BG_OR_ARENA]));
    sLog.outConfig("Death.Bones.World is set to ---------------------------- %s", sc.ToString(m_bool_configs[CONFIG_DEATH_BONES_WORLD]));
    sLog.outConfig("Death.CorpseReclaimDelay.PvE is set to ----------------- %s", sc.ToString(m_bool_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVE]));
    sLog.outConfig("Death.CorpseReclaimDelay.PvP is set to ----------------- %s", sc.ToString(m_bool_configs[CONFIG_DEATH_CORPSE_RECLAIM_DELAY_PVP]));
    sLog.outConfig("Death.SicknessLevel is set to -------------------------- %u", m_int_configs[CONFIG_DEATH_SICKNESS_LEVEL]);
    sLog.outConfig("Die.Command.Mode is set to ----------------------------- %s", sc.ToString(m_bool_configs[CONFIG_DIE_COMMAND_MODE]));
    sLog.outConfig("DurabilityLoss.InPvP is set to ------------------------- %s", sc.ToString(m_bool_configs[CONFIG_DURABILITY_LOSS_IN_PVP]));
    sLog.outConfig("DurabilityLoss.OnDeath is set to ----------------------- %f", rate_values[RATE_DURABILITY_LOSS_ON_DEATH]);
    sLog.outConfig("DurabilityLossChance.Absorb is set to ------------------ %f", rate_values[RATE_DURABILITY_LOSS_ABSORB]);
    sLog.outConfig("DurabilityLossChance.Block is set to ------------------- %f", rate_values[RATE_DURABILITY_LOSS_BLOCK]);
    sLog.outConfig("DurabilityLossChance.Damage is set to ------------------ %f", rate_values[RATE_DURABILITY_LOSS_DAMAGE]);
    sLog.outConfig("DurabilityLossChance.Parry is set to ------------------- %f", rate_values[RATE_DURABILITY_LOSS_PARRY]);
    sLog.outConfig("GuarderSight is set to --------------------------------- %f", m_float_configs[CONFIG_SIGHT_GUARDER]);
    sLog.outConfig("ListenRange.Say is set to ------------------------------ %f", m_float_configs[CONFIG_LISTEN_RANGE_SAY]);
    sLog.outConfig("ListenRange.TextEmote is set to ------------------------ %f", m_float_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE]);
    sLog.outConfig("ListenRange.Yell is set to ----------------------------- %f", m_float_configs[CONFIG_LISTEN_RANGE_YELL]);
    sLog.outConfig("MonsterSight is set to --------------------------------- %f", m_float_configs[CONFIG_SIGHT_MONSTER]);
    sLog.outConfig("Rate.Auction.Cut is set to ----------------------------- %f", rate_values[RATE_AUCTION_CUT]);
    sLog.outConfig("Rate.Auction.Deposit is set to ------------------------- %f", rate_values[RATE_AUCTION_DEPOSIT]);
    sLog.outConfig("Rate.Auction.Time is set to ---------------------------- %f", rate_values[RATE_AUCTION_TIME]);
    sLog.outConfig("Rate.Corpse.Decay.Looted is set to --------------------- %f", rate_values[RATE_CORPSE_DECAY_LOOTED]);
    sLog.outConfig("Rate.Creature.Aggro is set to -------------------------- %f", rate_values[RATE_CREATURE_AGGRO]);
    sLog.outConfig("Rate.Creature.Elite.Elite.Damage is set to ------------- %f", rate_values[RATE_CREATURE_ELITE_ELITE_DAMAGE]);
    sLog.outConfig("Rate.Creature.Elite.Elite.HP is set to ----------------- %f", rate_values[RATE_CREATURE_ELITE_ELITE_HP]);
    sLog.outConfig("Rate.Creature.Elite.Elite.SpellDamage is set to -------- %f", rate_values[RATE_CREATURE_ELITE_ELITE_SPELLDAMAGE]);
    sLog.outConfig("Rate.Creature.Elite.RARE.Damage is set to -------------- %f", rate_values[RATE_CREATURE_ELITE_RARE_DAMAGE]);
    sLog.outConfig("Rate.Creature.Elite.RARE.HP is set to ------------------ %f", rate_values[RATE_CREATURE_ELITE_RARE_HP]);
    sLog.outConfig("Rate.Creature.Elite.RARE.SpellDamage is set to --------- %f", rate_values[RATE_CREATURE_ELITE_RARE_SPELLDAMAGE]);
    sLog.outConfig("Rate.Creature.Elite.RAREELITE.Damage is set to --------- %f", rate_values[RATE_CREATURE_ELITE_RAREELITE_DAMAGE]);
    sLog.outConfig("Rate.Creature.Elite.RAREELITE.HP is set to ------------- %f", rate_values[RATE_CREATURE_ELITE_RAREELITE_HP]);
    sLog.outConfig("Rate.Creature.Elite.RAREELITE.SpellDamage is set to ---- %f", rate_values[RATE_CREATURE_ELITE_RAREELITE_SPELLDAMAGE]);
    sLog.outConfig("Rate.Creature.Elite.WORLDBOSS.Damage is set to --------- %f", rate_values[RATE_CREATURE_ELITE_WORLDBOSS_DAMAGE]);
    sLog.outConfig("Rate.Creature.Elite.WORLDBOSS.HP is set to ------------- %f", rate_values[RATE_CREATURE_ELITE_WORLDBOSS_HP]);
    sLog.outConfig("Rate.Creature.Elite.WORLDBOSS.SpellDamage is set to ---- %f", rate_values[RATE_CREATURE_ELITE_WORLDBOSS_SPELLDAMAGE]);
    sLog.outConfig("Rate.Creature.Normal.Damage is set to ------------------ %f", rate_values[RATE_CREATURE_NORMAL_DAMAGE]);
    sLog.outConfig("Rate.Creature.Normal.HP is set to ---------------------- %f", rate_values[RATE_CREATURE_NORMAL_HP]);
    sLog.outConfig("Rate.Creature.Normal.SpellDamage is set to ------------- %f", rate_values[RATE_CREATURE_NORMAL_SPELLDAMAGE]);
    sLog.outConfig("Rate.Damage.Fall is set to ----------------------------- %f", rate_values[RATE_DAMAGE_FALL]);
    sLog.outConfig("Rate.Drop.Item.Artifact is set to ---------------------- %f", rate_values[RATE_DROP_ITEM_ARTIFACT]);
    sLog.outConfig("Rate.Drop.Item.Epic is set to -------------------------- %f", rate_values[RATE_DROP_ITEM_EPIC]);
    sLog.outConfig("Rate.Drop.Item.Legendary is set to --------------------- %f", rate_values[RATE_DROP_ITEM_LEGENDARY]);
    sLog.outConfig("Rate.Drop.Item.Normal is set to ------------------------ %f", rate_values[RATE_DROP_ITEM_NORMAL]);
    sLog.outConfig("Rate.Drop.Item.Poor is set to -------------------------- %f", rate_values[RATE_DROP_ITEM_POOR]);
    sLog.outConfig("Rate.Drop.Item.Rare is set to -------------------------- %f", rate_values[RATE_DROP_ITEM_RARE]);
    sLog.outConfig("Rate.Drop.Item.Referenced is set to -------------------- %f", rate_values[RATE_DROP_ITEM_REFERENCED]);
    sLog.outConfig("Rate.Drop.Item.ReferencedAmount is set to -------------- %f", rate_values[RATE_DROP_ITEM_REFERENCED_AMOUNT]);
    sLog.outConfig("Rate.Drop.Item.Uncommon is set to ---------------------- %f", rate_values[RATE_DROP_ITEM_UNCOMMON]);
    sLog.outConfig("Rate.Drop.Money is set to ------------------------------ %f", rate_values[RATE_DROP_MONEY]);
    sLog.outConfig("Rate.Focus is set to ----------------------------------- %f", rate_values[RATE_POWER_FOCUS]);
    sLog.outConfig("Rate.Energy is set to ---------------------------------- %f", rate_values[RATE_POWER_ENERGY]);
    sLog.outConfig("Rate.Health is set to ---------------------------------- %f", rate_values[RATE_HEALTH]);
    sLog.outConfig("Rate.Honor is set to ----------------------------------- %f", rate_values[RATE_HONOR]);
    sLog.outConfig("Rate.InstanceResetTime is set to ----------------------- %f", rate_values[RATE_INSTANCE_RESET_TIME]);
    sLog.outConfig("Rate.Mana is set to ------------------------------------ %f", rate_values[RATE_POWER_MANA]);
    sLog.outConfig("Rate.Mining.Amount is set to --------------------------- %f", rate_values[RATE_MINING_AMOUNT]);
    sLog.outConfig("Rate.Mining.Next is set to ----------------------------- %f", rate_values[RATE_MINING_NEXT]);
    sLog.outConfig("Rate.MoveSpeed is set to ------------------------------- %f", rate_values[RATE_MOVESPEED]);
    sLog.outConfig("Rate.Rage.Income is set to ----------------------------- %f", rate_values[RATE_POWER_RAGE_INCOME]);
    sLog.outConfig("Rate.Rage.Loss is set to ------------------------------- %f", rate_values[RATE_POWER_RAGE_LOSS]);
    sLog.outConfig("Rate.RepairCost is set to ------------------------------ %f", rate_values[RATE_REPAIRCOST]);
    sLog.outConfig("Rate.Reputation.Gain is set to ------------------------- %f", rate_values[RATE_REPUTATION_GAIN]);
    sLog.outConfig("Rate.Reputation.LowLevel.Kill is set to ---------------- %f", rate_values[RATE_REPUTATION_LOWLEVEL_KILL]);
    sLog.outConfig("Rate.Reputation.LowLevel.Quest is set to --------------- %f", rate_values[RATE_REPUTATION_LOWLEVEL_QUEST]);
    sLog.outConfig("Rate.Reputation.RecruitAFriendBonus is set to ---------- %f", rate_values[RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS]);
    sLog.outConfig("Rate.Rest.InGame is set to ----------------------------- %f", rate_values[RATE_REST_INGAME]);
    sLog.outConfig("Rate.Rest.Offline.InTavernOrCity is set to ------------- %f", rate_values[RATE_REST_OFFLINE_IN_TAVERN_OR_CITY]);
    sLog.outConfig("Rate.Rest.Offline.InWilderness is set to --------------- %f", rate_values[RATE_REST_OFFLINE_IN_WILDERNESS]);
    sLog.outConfig("Rate.RunicPower.Income is set to ----------------------- %f", rate_values[RATE_POWER_RUNICPOWER_INCOME]);
    sLog.outConfig("Rate.RunicPower.Loss is set to ------------------------- %f", rate_values[RATE_POWER_RUNICPOWER_LOSS]);
    sLog.outConfig("Rate.Skill.Discovery is set to ------------------------- %f", rate_values[RATE_SKILL_DISCOVERY]);
    sLog.outConfig("Rate.Talent is set to ---------------------------------- %f", rate_values[RATE_TALENT]);
    sLog.outConfig("Rate.XP.Explore is set to ------------------------------ %f", rate_values[RATE_XP_EXPLORE]);
    sLog.outConfig("Rate.XP.Kill is set to --------------------------------- %f", rate_values[RATE_XP_KILL]);
    sLog.outConfig("Rate.XP.Quest is set to -------------------------------- %f", rate_values[RATE_XP_QUEST]);
    sLog.outConfig("SkillChance.Green is set to ---------------------------- %u", m_int_configs[CONFIG_SKILL_CHANCE_GREEN]);
    sLog.outConfig("SkillChance.Grey is set to ----------------------------- %u", m_int_configs[CONFIG_SKILL_CHANCE_GREY]);
    sLog.outConfig("SkillChance.MiningSteps is set to ---------------------- %u", m_int_configs[CONFIG_SKILL_CHANCE_MINING_STEPS]);
    sLog.outConfig("SkillChance.Orange is set to --------------------------- %u", m_int_configs[CONFIG_SKILL_CHANCE_ORANGE]);
    sLog.outConfig("SkillChance.SkinningSteps is set to -------------------- %u", m_int_configs[CONFIG_SKILL_CHANCE_SKINNING_STEPS]);
    sLog.outConfig("SkillChance.Yellow is set to --------------------------- %u", m_int_configs[CONFIG_SKILL_CHANCE_YELLOW]);
    sLog.outConfig("SkillGain.Crafting is set to --------------------------- %u", m_int_configs[CONFIG_SKILL_GAIN_CRAFTING]);
    sLog.outConfig("SkillGain.Defense is set to ---------------------------- %u", m_int_configs[CONFIG_SKILL_GAIN_DEFENSE]);
    sLog.outConfig("SkillGain.Gathering is set to -------------------------- %u", m_int_configs[CONFIG_SKILL_GAIN_GATHERING]);
    sLog.outConfig("SkillGain.Weapon is set to ----------------------------- %u", m_int_configs[CONFIG_SKILL_GAIN_WEAPON]);
    sLog.outConfig("ThreatRadius is set to --------------------------------- %f", m_float_configs[CONFIG_THREAT_RADIUS]);
    sLog.outConfig("TargetPosRecalculateRange is set to -------------------- %f", rate_values[RATE_TARGET_POS_RECALCULATION_RANGE]);
    sLog.outConfig("WorldBossLevelDiff is set to --------------------------- %u", m_int_configs[CONFIG_WORLD_BOSS_LEVEL_DIFF]);

    /// - broadcast configs begin
    m_bool_configs[CONFIG_AUTOBROADCAST]            = false;
    m_int_configs[CONFIG_AUTOBROADCAST_CENTER]      = 0;
    m_int_configs[CONFIG_AUTOBROADCAST_INTERVAL]    = 60000;

    if (c_09_auto_broadcast)                                              
    {
        sLog.outString("Loading broadcast settings...");
        barGoLink bar(c_09_auto_broadcast->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_09_auto_broadcast->Fetch();

            if (fields[0].GetString() == "AutoBroadcast.On")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AUTOBROADCAST] = true;

            if (fields[0].GetString() == "AutoBroadcast.Center")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AUTOBROADCAST_CENTER])
                    m_int_configs[CONFIG_AUTOBROADCAST_CENTER] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AutoBroadcast.Timer")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AUTOBROADCAST_INTERVAL])
                    m_int_configs[CONFIG_AUTOBROADCAST_INTERVAL] = fields[1].GetUInt32();

            ++count;
        }
        while (c_09_auto_broadcast->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u broadcast settings", count);
    }                                                               

    sLog.outConfig(" ~~~~~~~~~~== Auto Broadcast Settings ==~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("AutoBroadcast.On is set to ----------------------------- %s", sc.ToString(m_bool_configs[CONFIG_AUTOBROADCAST]));
    sLog.outConfig("AutoBroadcast.Center is set to ------------------------- %u", m_int_configs[CONFIG_AUTOBROADCAST_CENTER]);
    sLog.outConfig("AutoBroadcast.Timer is set to -------------------------- %u", m_int_configs[CONFIG_AUTOBROADCAST_INTERVAL]);

    /// - battleground configs begin
    m_int_configs[CONFIG_RANDOM_BG_RESET_HOUR]                      = 6;
    m_bool_configs[CONFIG_BATTLEGROUND_CAST_DESERTER]               = true;
    m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE]      = false;
    m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY]  = false;
    m_int_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE]              = 0;
    m_int_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER]       = 300000;
    m_int_configs[CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH] = 1800000;
    m_bool_configs[CONFIG_BG_XP_FOR_KILL]                           = false;

    if (c_10_battleground_settings)
    {
        sLog.outString("Loading battleground settings...");
        barGoLink bar(c_10_battleground_settings->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_10_battleground_settings->Fetch();

            if (fields[0].GetString() == "Battleground.Random.ResetHour")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_RANDOM_BG_RESET_HOUR])
                    m_int_configs[CONFIG_RANDOM_BG_RESET_HOUR] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Battleground.CastDeserter")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_BATTLEGROUND_CAST_DESERTER] = false;

            if (fields[0].GetString() == "Battleground.QueueAnnouncer.Enable")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE] = true;

            if (fields[0].GetString() == "Battleground.QueueAnnouncer.PlayerOnly")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY] = true;

            if (fields[0].GetString() == "Battleground.InvitationType")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE])
                    m_int_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Battleground.PrematureFinishTimer")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER])
                    m_int_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Battleground.PremadeGroupWaitForMatch")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH])
                    m_int_configs[CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Battleground.GiveXPForKills")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_BG_XP_FOR_KILL] = true;

            ++count;
        }
        while (c_10_battleground_settings->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u battleground settings", count);
    }                                                                

    if (m_int_configs[CONFIG_RANDOM_BG_RESET_HOUR] > 23)
    {
        sLog.outError("Battleground.Random.ResetHour (%u) can't be load. Set to 6.", m_int_configs[CONFIG_RANDOM_BG_RESET_HOUR]);
        m_int_configs[CONFIG_RANDOM_BG_RESET_HOUR] = 6;
    }

    sLog.outConfig(" ~~~~~~~~~~~== Battleground Settings ==~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("Battleground.CastDeserter is set to -------------------- %s", sc.ToString(m_bool_configs[CONFIG_BATTLEGROUND_CAST_DESERTER]));
    sLog.outConfig("Battleground.GiveXPForKills is set to ------------------ %s", sc.ToString(m_bool_configs[CONFIG_BG_XP_FOR_KILL]));
    sLog.outConfig("Battleground.InvitationType is set to ------------------ %u", m_int_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE]);
    sLog.outConfig("Battleground.PremadeGroupWaitForMatch is set to -------- %u", m_int_configs[CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH]);
    sLog.outConfig("Battleground.PrematureFinishTimer is set to ------------ %u", m_int_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER]);
    sLog.outConfig("Battleground.QueueAnnouncer.Enable is set to ----------- %s", sc.ToString(m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE]));
    sLog.outConfig("Battleground.QueueAnnouncer.PlayerOnly is set to ------- %s", sc.ToString(m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY]));
    sLog.outConfig("Battleground.Random.ResetHour is set to ---------------- %u", m_int_configs[CONFIG_RANDOM_BG_RESET_HOUR]);

    /// - arena configs begin
    m_int_configs[CONFIG_ARENA_MAX_RATING_DIFFERENCE]           = 150;
    m_int_configs[CONFIG_ARENA_RATING_DISCARD_TIMER]            = 600000;
    m_bool_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS]         = false;
    m_int_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS]   = 7;
    m_bool_configs[CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE]         = false;
    m_bool_configs[CONFIG_ARENA_QUEUE_ANNOUNCER_PLAYERONLY]     = false;
    m_int_configs[CONFIG_ARENA_SEASON_ID]                       = 1;
    m_int_configs[CONFIG_ARENA_START_RATING]                    = 0;
    m_int_configs[CONFIG_ARENA_START_PERSONAL_RATING]           = 0;
    m_int_configs[CONFIG_ARENA_START_MATCHMAKER_RATING]         = 1500;
    m_bool_configs[CONFIG_ARENA_SEASON_IN_PROGRESS]             = true;

    if (c_11_arena_settings)
    {
        sLog.outString("Loading arena settings...");
        barGoLink bar(c_11_arena_settings->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_11_arena_settings->Fetch();

            if (fields[0].GetString() == "Arena.MaxRatingDifference")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_ARENA_MAX_RATING_DIFFERENCE])
                    m_int_configs[CONFIG_ARENA_MAX_RATING_DIFFERENCE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Arena.RatingDiscardTimer")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_ARENA_RATING_DISCARD_TIMER])
                    m_int_configs[CONFIG_ARENA_RATING_DISCARD_TIMER] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Arena.AutoDistributePoints")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS] = true;

            if (fields[0].GetString() == "Arena.AutoDistributeIntervall")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS])
                    m_int_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Arena.QueueAnnouncer.Enable")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE] = true;

            if (fields[0].GetString() == "Arena.QueueAnnouncer.PlayerOnly")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ARENA_QUEUE_ANNOUNCER_PLAYERONLY] = true;

            if (fields[0].GetString() == "Arena.ArenaSeason.ID")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_ARENA_SEASON_ID])
                    m_int_configs[CONFIG_ARENA_SEASON_ID] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Arena.ArenaStartRating")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_ARENA_START_RATING])
                    m_int_configs[CONFIG_ARENA_START_RATING] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Arena.ArenaStartPersonalRating")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_ARENA_START_PERSONAL_RATING])
                    m_int_configs[CONFIG_ARENA_START_PERSONAL_RATING] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Arena.ArenaStartMatchmakerRating")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_ARENA_START_MATCHMAKER_RATING])
                    m_int_configs[CONFIG_ARENA_START_MATCHMAKER_RATING] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Arena.ArenaSeason.InProgress")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_ARENA_SEASON_IN_PROGRESS] = false;

            ++count;
        }
        while (c_11_arena_settings->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u arena settings", count);
    } 

    sLog.outConfig(" ~~~~~~~~~~~~~~== Arena Settings ==~~~~~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("Arena.ArenaSeason.ID is set to ------------------------- %u", m_int_configs[CONFIG_ARENA_SEASON_ID]);
    sLog.outConfig("Arena.ArenaSeason.InProgress is set to ----------------- %s", sc.ToString(m_bool_configs[CONFIG_ARENA_SEASON_IN_PROGRESS]));
    sLog.outConfig("Arena.ArenaStartMatchmakerRating is set to ------------- %u", m_int_configs[CONFIG_ARENA_START_MATCHMAKER_RATING]);
    sLog.outConfig("Arena.ArenaStartPersonalRating is set to --------------- %u", m_int_configs[CONFIG_ARENA_START_PERSONAL_RATING]);
    sLog.outConfig("Arena.ArenaStartRating is set to ----------------------- %u", m_int_configs[CONFIG_ARENA_START_RATING]);
    sLog.outConfig("Arena.AutoDistributeIntervall is set to ---------------- %u", m_int_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS]);
    sLog.outConfig("Arena.AutoDistributePoints is set to ------------------- %s", sc.ToString(m_bool_configs[CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS]));
    sLog.outConfig("Arena.MaxRatingDifference is set to -------------------- %u", m_int_configs[CONFIG_ARENA_MAX_RATING_DIFFERENCE]);
    sLog.outConfig("Arena.QueueAnnouncer.Enable is set to ------------------ %s", sc.ToString(m_bool_configs[CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE]));
    sLog.outConfig("Arena.QueueAnnouncer.PlayerOnly is set to -------------- %s", sc.ToString(m_bool_configs[CONFIG_ARENA_QUEUE_ANNOUNCER_PLAYERONLY]));
    sLog.outConfig("Arena.RatingDiscardTimer is set to --------------------- %u", m_int_configs[CONFIG_ARENA_RATING_DISCARD_TIMER]);

    /// - network configs begin
    m_bool_configs[CONFIG_NET_TCP_NO_DELAY] = true;
    m_int_configs[CONFIG_NET_THREADS]       = 1;
    m_int_configs[CONFIG_NET_OUT_K_BUFF]    = -1;
    m_int_configs[CONFIG_NET_OUT_U_BUFF]    = 65536;

    if (c_12_network_settings)                                                 
    {
        sLog.outString("Loading network settings...");
        barGoLink bar(c_12_network_settings->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_12_network_settings->Fetch();

            if (fields[0].GetString() == "Network.Threads")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_NET_THREADS])
                    m_int_configs[CONFIG_NET_THREADS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Network.TcpNodelay")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_NET_TCP_NO_DELAY] = false;

            if (fields[0].GetString() == "Network.OutKBuff")
                if (fields[1].GetInt32() != m_int_configs[CONFIG_NET_OUT_K_BUFF])
                    m_int_configs[CONFIG_NET_OUT_K_BUFF] = fields[1].GetInt32();

            if (fields[0].GetString() == "Network.OutUBuff")
                if (fields[1].GetInt32() != m_int_configs[CONFIG_NET_OUT_U_BUFF])
                    m_int_configs[CONFIG_NET_OUT_U_BUFF] = fields[1].GetInt32();

            ++count;
        }
        while (c_12_network_settings->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u network settings", count);
    }

    if (m_int_configs[CONFIG_NET_THREADS] <= 0)
    {
        sLog.outError("Network.Threads is wrong in your Config DB");
        m_int_configs[CONFIG_NET_THREADS] = 1;
    }
    if (m_int_configs[CONFIG_NET_OUT_U_BUFF] <= 0)
    {
        sLog.outError("Network.OutUBuff is wrong in your Config DB");
        m_int_configs[CONFIG_NET_OUT_U_BUFF] = 65536;
    }

    sLog.outConfig(" ~~~~~~~~~~~~~== Network Settings ==~~~~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("Network.Threads is set to ------------------------------ %u", m_int_configs[CONFIG_NET_THREADS]);
    sLog.outConfig("Network.TcpNodelay is set to --------------------------- %s", sc.ToString(m_bool_configs[CONFIG_NET_TCP_NO_DELAY]));
    sLog.outConfig("Network.OutUBuff is set to ----------------------------- %u", m_int_configs[CONFIG_NET_OUT_U_BUFF]);
    sLog.outConfig("Network.OutKBuff is set to ----------------------------- %i", m_int_configs[CONFIG_NET_OUT_K_BUFF]);

    /// - auctionhouse bot configs begin
    m_int_configs[CONFIG_AHB_ACCOUNT]                            = 0;
    m_int_configs[CONFIG_AHB_GUID]                               = 0;
    m_int_configs[CONFIG_AHB_ITEMS_PER_CYCLE]                    = 200;
    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_GUID]           = 0;
    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_LEVEL]          = 0;
    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_REQ_LEVEL]      = 0;
    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_REQ_SKILL_RANK] = 0;
    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_GUID]           = 0;
    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_LEVEL]          = 0;
    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_REQ_LEVEL]      = 0;
    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_REQ_SKILL_RANK] = 0;
    m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_GUID]             = 0;
    m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_LEVEL]            = 0;
    m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_REQ_LEVEL]        = 0;
    m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_REQ_SKILL_RANK]   = 0;
    m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_GUID]             = 0;
    m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_LEVEL]            = 0;
    m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_REQ_LEVEL]        = 0;
    m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_REQ_SKILL_RANK]   = 0;
    m_bool_configs[CONFIG_AHB_BIND_QUEST_ITEM]                   = false;
    m_bool_configs[CONFIG_AHB_BIND_WHEN_EQUIPPED]                = true;
    m_bool_configs[CONFIG_AHB_BIND_WHEN_PICKED_UP]               = false;
    m_bool_configs[CONFIG_AHB_BIND_WHEN_USE]                     = true;
    m_bool_configs[CONFIG_AHB_DEBUG]                             = false;
    m_bool_configs[CONFIG_AHB_DEBUG_FILTERS]                     = false;
    m_bool_configs[CONFIG_AHB_DISABLE_BETA_PTR_UNUSED]           = false;
    m_bool_configs[CONFIG_AHB_DISABLE_BOP_OR_QUEST_NOREQ_LEVEL]  = false;
    m_bool_configs[CONFIG_AHB_DISABLE_CONJURED]                  = false;
    m_bool_configs[CONFIG_AHB_DISABLE_DK_ITEMS]                  = false;
    m_bool_configs[CONFIG_AHB_DISABLE_DRUID_ITEMS]               = false;
    m_bool_configs[CONFIG_AHB_DISABLE_DURATION]                  = false;
    m_bool_configs[CONFIG_AHB_DISABLE_GEMS]                      = false;
    m_bool_configs[CONFIG_AHB_DISABLE_HUNTER_ITEMS]              = false;
    m_bool_configs[CONFIG_AHB_DISABLE_KEYS]                      = false;
    m_bool_configs[CONFIG_AHB_DISABLE_LOOTABLE]                  = false;
    m_bool_configs[CONFIG_AHB_DISABLE_MAGE_ITEMS]                = false;
    m_bool_configs[CONFIG_AHB_DISABLE_MONEY]                     = false;
    m_bool_configs[CONFIG_AHB_DISABLE_MONEY_LOOT]                = false;
    m_bool_configs[CONFIG_AHB_DISABLE_PALADIN_ITEMS]             = false;
    m_bool_configs[CONFIG_AHB_DISABLE_PERM_ENCHANT]              = false;
    m_bool_configs[CONFIG_AHB_DISABLE_PRIEST_ITEMS]              = false;
    m_bool_configs[CONFIG_AHB_DISABLE_ROGUE_ITEMS]               = false;
    m_bool_configs[CONFIG_AHB_DISABLE_SHAMAN_ITEMS]              = false;
    m_bool_configs[CONFIG_AHB_DISABLE_UNUSED_CLASS_ITEMS]        = false;
    m_bool_configs[CONFIG_AHB_DISABLE_WARLOCK_ITEMS]             = false;
    m_bool_configs[CONFIG_AHB_DISABLE_WARRIOR_ITEMS]             = false;
    m_bool_configs[CONFIG_AHB_ENABLE_BUYER]                      = false;
    m_bool_configs[CONFIG_AHB_ENABLE_SELLER]                     = false;
    m_bool_configs[CONFIG_AHB_LOOT_ITEMS]                        = true;
    m_bool_configs[CONFIG_AHB_LOOT_TRADE_GOODS]                  = true;
    m_bool_configs[CONFIG_AHB_NO_BIND]                           = true;
    m_bool_configs[CONFIG_AHB_OTHER_ITEMS]                       = false;
    m_bool_configs[CONFIG_AHB_OTHER_TRADE_GOODS]                 = false;
    m_bool_configs[CONFIG_AHB_USE_BUY_PRICE_FOR_BUYER]           = false;
    m_bool_configs[CONFIG_AHB_USE_BUY_PRICE_FOR_SELLER]          = false;
    m_bool_configs[CONFIG_AHB_VENDOR_ITEMS]                      = false;
    m_bool_configs[CONFIG_AHB_VENDOR_TRADE_GOODS]                = false;

    if (c_13_auctionhouse_bot_settings)                                                 
    {
        sLog.outString("Loading auctionhouse bot settings...");
        barGoLink bar(c_13_auctionhouse_bot_settings->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_13_auctionhouse_bot_settings->Fetch();

            if (fields[0].GetString() == "AuctionHouseBot.Account")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_ACCOUNT])
                    m_int_configs[CONFIG_AHB_ACCOUNT] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.GUID")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_GUID])
                    m_int_configs[CONFIG_AHB_GUID] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.ItemsPerCycle")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_ITEMS_PER_CYCLE])
                    m_int_configs[CONFIG_AHB_ITEMS_PER_CYCLE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableItemsAboveGUID")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_GUID])
                    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_GUID] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableItemsAboveLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_LEVEL])
                    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableItemsAboveReqLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_REQ_LEVEL])
                    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_REQ_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableItemsAboveReqSkillRank")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_REQ_SKILL_RANK])
                    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_REQ_SKILL_RANK] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableItemsBelowGUID")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_GUID])
                    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_GUID] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableItemsBelowLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_LEVEL])
                    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableItemsBelowReqLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_REQ_LEVEL])
                    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_REQ_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableItemsBelowReqSkillRank")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_REQ_SKILL_RANK])
                    m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_REQ_SKILL_RANK] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableTGsAboveGUID")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_GUID])
                    m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_GUID] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableTGsAboveLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_LEVEL])
                    m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableTGsAboveReqLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_REQ_LEVEL])
                    m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_REQ_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableTGsAboveReqSkillRank")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_REQ_SKILL_RANK])
                    m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_REQ_SKILL_RANK] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableTGsBelowGUID")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_GUID])
                    m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_GUID] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableTGsBelowLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_LEVEL])
                    m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableTGsBelowReqLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_REQ_LEVEL])
                    m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_REQ_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.DisableTGsBelowReqSkillRank")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_REQ_SKILL_RANK])
                    m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_REQ_SKILL_RANK] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AuctionHouseBot.Bind_When_Equipped")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_BIND_WHEN_EQUIPPED] = false;

            if (fields[0].GetString() == "AuctionHouseBot.Bind_When_Use")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_BIND_WHEN_USE] = false;

            if (fields[0].GetString() == "AuctionHouseBot.LootItems")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_LOOT_ITEMS] = false;

            if (fields[0].GetString() == "AuctionHouseBot.LootTradeGoods")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_LOOT_TRADE_GOODS] = false;

            if (fields[0].GetString() == "AuctionHouseBot.No_Bind")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_NO_BIND] = false;

            if (fields[0].GetString() == "AuctionHouseBot.Bind_Quest_Item")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_BIND_QUEST_ITEM] = true;

            if (fields[0].GetString() == "AuctionHouseBot.Bind_Quest_Item")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_BIND_WHEN_PICKED_UP] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DEBUG")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DEBUG] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DEBUG_FILTERS")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DEBUG_FILTERS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableBeta_PTR_Unused")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_BETA_PTR_UNUSED] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_BOP_OR_QUEST_NOREQ_LEVEL] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableConjured")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_CONJURED] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableDKItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_DK_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableDruidItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_DRUID_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableDuration")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_DURATION] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableGems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_GEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableHunterItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_HUNTER_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableKeys")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_KEYS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableLootable")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_LOOTABLE] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableMageItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_MAGE_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableMoney")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_MONEY] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableMoneyLoot")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_MONEY_LOOT] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisablePaladinItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_PALADIN_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisablePermEnchant")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_PERM_ENCHANT] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisablePriestItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_PRIEST_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableRogueItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_ROGUE_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableShamanItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_SHAMAN_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableUnusedClassItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_UNUSED_CLASS_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableWarlockItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_WARLOCK_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.DisableWarriorItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_DISABLE_WARRIOR_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.EnableBuyer")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_ENABLE_BUYER] = true;

            if (fields[0].GetString() == "AuctionHouseBot.EnableSeller")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_ENABLE_SELLER] = true;

            if (fields[0].GetString() == "AuctionHouseBot.OtherItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_OTHER_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.OtherTradeGoods")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_OTHER_TRADE_GOODS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.UseBuyPriceForBuyer")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_USE_BUY_PRICE_FOR_BUYER] = true;

            if (fields[0].GetString() == "AuctionHouseBot.UseBuyPriceForSeller")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_USE_BUY_PRICE_FOR_SELLER] = true;

            if (fields[0].GetString() == "AuctionHouseBot.VendorItems")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_VENDOR_ITEMS] = true;

            if (fields[0].GetString() == "AuctionHouseBot.VendorTradeGoods")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_AHB_VENDOR_TRADE_GOODS] = true;

            ++count;
        }
        while (c_13_auctionhouse_bot_settings->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u auctionhouse bot settings", count);
    }                                                                  

    sLog.outConfig(" ~~~~~~~~~== AuctionHouse Bot Settings ==~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("AuctionHouseBot.Account is set to ---------------------- %u", m_int_configs[CONFIG_AHB_ACCOUNT]);
    sLog.outConfig("AuctionHouseBot.GUID is set to ------------------------- %u", m_int_configs[CONFIG_AHB_GUID]);
    sLog.outConfig("AuctionHouseBot.EnableBuyer is set to ------------------ %s", sc.ToString(m_bool_configs[CONFIG_AHB_ENABLE_BUYER]));                      
    sLog.outConfig("AuctionHouseBot.EnableSeller is set to ----------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_ENABLE_SELLER]));                     
    sLog.outConfig("AuctionHouseBot.ItemsPerCycle is set to ---------------- %u", m_int_configs[CONFIG_AHB_ITEMS_PER_CYCLE]);
    sLog.outConfig("AuctionHouseBot.DEBUG is set to ------------------------ %s", sc.ToString(m_bool_configs[CONFIG_AHB_DEBUG]));                             
    sLog.outConfig("AuctionHouseBot.DEBUG_FILTERS is set to ---------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DEBUG_FILTERS]));                     
    sLog.outConfig("AuctionHouseBot.No_Bind is set to ---------------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_NO_BIND]));                        
    sLog.outConfig("AuctionHouseBot.Bind_Quest_Item is set to -------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_BIND_QUEST_ITEM]));                   
    sLog.outConfig("AuctionHouseBot.Bind_When_Equipped is set to ----------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_BIND_WHEN_EQUIPPED]));              
    sLog.outConfig("AuctionHouseBot.Bind_When_Picked_Up is set to ---------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_BIND_WHEN_PICKED_UP]));               
    sLog.outConfig("AuctionHouseBot.Bind_When_Use is set to ---------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_BIND_WHEN_USE]));                    
    sLog.outConfig("AuctionHouseBot.DisableBeta_PTR_Unused is set to ------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_BETA_PTR_UNUSED]));           
    sLog.outConfig("AuctionHouseBot.DisableBOP_Or_Quest_NoReqLevel is set to %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_BOP_OR_QUEST_NOREQ_LEVEL]));  
    sLog.outConfig("AuctionHouseBot.DisableConjured is set to -------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_CONJURED]));                  
    sLog.outConfig("AuctionHouseBot.DisableDuration is set to -------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_DURATION]));                  
    sLog.outConfig("AuctionHouseBot.DisableGems is set to ------------------ %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_GEMS]));                      
    sLog.outConfig("AuctionHouseBot.DisableKeys is set to ------------------ %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_KEYS]));                      
    sLog.outConfig("AuctionHouseBot.DisableLootable is set to -------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_LOOTABLE]));                  
    sLog.outConfig("AuctionHouseBot.DisableMoney is set to ----------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_MONEY]));                     
    sLog.outConfig("AuctionHouseBot.DisableMoneyLoot is set to ------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_MONEY_LOOT]));                
    sLog.outConfig("AuctionHouseBot.DisablePermEnchant is set to ----------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_PERM_ENCHANT]));              
    sLog.outConfig("AuctionHouseBot.DisableItemsAboveGUID is set to -------- %u", m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_GUID]);
    sLog.outConfig("AuctionHouseBot.DisableItemsAboveLevel is set to ------- %u", m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_LEVEL]);
    sLog.outConfig("AuctionHouseBot.DisableItemsAboveReqLevel is set to ---- %u", m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_REQ_LEVEL]);
    sLog.outConfig("AuctionHouseBot.DisableItemsAboveReqSkillRank is set to  %u", m_int_configs[CONFIG_AHB_DISABLE_ITEMS_ABOVE_REQ_SKILL_RANK]);
    sLog.outConfig("AuctionHouseBot.DisableItemsBelowGUID is set to -------- %u", m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_GUID]);
    sLog.outConfig("AuctionHouseBot.DisableItemsBelowLevel is set to ------- %u", m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_LEVEL]);
    sLog.outConfig("AuctionHouseBot.DisableItemsBelowReqLevel is set to ---- %u", m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_REQ_LEVEL]);
    sLog.outConfig("AuctionHouseBot.DisableItemsBelowReqSkillRank is set to  %u", m_int_configs[CONFIG_AHB_DISABLE_ITEMS_BELOW_REQ_SKILL_RANK]);
    sLog.outConfig("AuctionHouseBot.DisableTGsAboveGUID is set to ---------- %u", m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_GUID]);
    sLog.outConfig("AuctionHouseBot.DisableTGsAboveLevel is set to --------- %u", m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_LEVEL]);
    sLog.outConfig("AuctionHouseBot.DisableTGsAboveReqLevel is set to ------ %u", m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_REQ_LEVEL]);
    sLog.outConfig("AuctionHouseBot.DisableTGsAboveReqSkillRank is set to -- %u", m_int_configs[CONFIG_AHB_DISABLE_TGS_ABOVE_REQ_SKILL_RANK]);
    sLog.outConfig("AuctionHouseBot.DisableTGsBelowGUID is set to ---------- %u", m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_GUID]);
    sLog.outConfig("AuctionHouseBot.DisableTGsBelowLevel is set to --------- %u", m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_LEVEL]);
    sLog.outConfig("AuctionHouseBot.DisableTGsBelowReqLevel is set to ------ %u", m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_REQ_LEVEL]);
    sLog.outConfig("AuctionHouseBot.DisableTGsBelowReqSkillRank is set to -- %u", m_int_configs[CONFIG_AHB_DISABLE_TGS_BELOW_REQ_SKILL_RANK]);
    sLog.outConfig("AuctionHouseBot.DisableDKItems is set to --------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_DK_ITEMS]));                  
    sLog.outConfig("AuctionHouseBot.DisableDruidItems is set to ------------ %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_DRUID_ITEMS]));               
    sLog.outConfig("AuctionHouseBot.DisableHunterItems is set to ----------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_HUNTER_ITEMS]));              
    sLog.outConfig("AuctionHouseBot.DisableMageItems is set to ------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_MAGE_ITEMS]));                
    sLog.outConfig("AuctionHouseBot.DisablePaladinItems is set to ---------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_PALADIN_ITEMS]));             
    sLog.outConfig("AuctionHouseBot.DisablePriestItems is set to ----------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_PRIEST_ITEMS]));              
    sLog.outConfig("AuctionHouseBot.DisableRogueItems is set to ------------ %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_ROGUE_ITEMS]));               
    sLog.outConfig("AuctionHouseBot.DisableShamanItems is set to ----------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_SHAMAN_ITEMS]));              
    sLog.outConfig("AuctionHouseBot.DisableUnusedClassItems is set to ------ %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_UNUSED_CLASS_ITEMS]));        
    sLog.outConfig("AuctionHouseBot.DisableWarlockItems is set to ---------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_WARLOCK_ITEMS]));             
    sLog.outConfig("AuctionHouseBot.DisableWarriorItems is set to ---------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_DISABLE_WARRIOR_ITEMS]));             
    sLog.outConfig("AuctionHouseBot.LootItems is set to -------------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_LOOT_ITEMS]));                      
    sLog.outConfig("AuctionHouseBot.LootTradeGoods is set to --------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_LOOT_TRADE_GOODS]));             
    sLog.outConfig("AuctionHouseBot.OtherItems is set to ------------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_OTHER_ITEMS]));                       
    sLog.outConfig("AuctionHouseBot.OtherTradeGoods is set to -------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_OTHER_TRADE_GOODS]));                 
    sLog.outConfig("AuctionHouseBot.UseBuyPriceForBuyer is set to ---------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_USE_BUY_PRICE_FOR_BUYER]));           
    sLog.outConfig("AuctionHouseBot.UseBuyPriceForSeller is set to --------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_USE_BUY_PRICE_FOR_SELLER]));          
    sLog.outConfig("AuctionHouseBot.VendorItems is set to ------------------ %s", sc.ToString(m_bool_configs[CONFIG_AHB_VENDOR_ITEMS]));                      
    sLog.outConfig("AuctionHouseBot.VendorTradeGoods is set to ------------- %s", sc.ToString(m_bool_configs[CONFIG_AHB_VENDOR_TRADE_GOODS]));                

    /// - console and remote access configs begin
    m_bool_configs[CONFIG_CONSOLE_ENABLED] = true;
    m_bool_configs[CONFIG_RA_ENABLE]       = false;
    m_int_configs[CONFIG_RA_PORT]          = 3443;
    string_ra_ip                           = "0.0.0.0";
    m_int_configs[CONFIG_RA_MIN_LEVEL]     = 3;
    m_bool_configs[CONFIG_SOAP_ENABLED]    = false;
    string_soap_ip                         = "127.0.0.1";
    m_int_configs[CONFIG_SOAP_PORT]        = 7878;

    if (c_14_console)                                                 
    {
        sLog.outString("Loading console and remote settings...");
        barGoLink bar(c_14_console->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_14_console->Fetch();

            if (fields[0].GetString() == "Console.Enable")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_CONSOLE_ENABLED] = false;

            if (fields[0].GetString() == "Ra.Enable")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_RA_ENABLE] = true;

            if (fields[0].GetString() == "RA.IP")
                if (fields[1].GetString() != string_ra_ip)
                    string_ra_ip = fields[1].GetString();

            if (fields[0].GetString() == "Ra.Port")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_RA_PORT])
                    m_int_configs[CONFIG_RA_PORT] = fields[1].GetUInt32();

            if (fields[0].GetString() == "RA.MinLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_RA_MIN_LEVEL])
                    m_int_configs[CONFIG_RA_MIN_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "SOAP.Enabled")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_SOAP_ENABLED] = true;

            if (fields[0].GetString() == "SOAP.IP")
                if (fields[1].GetString() != string_soap_ip)
                    string_soap_ip = fields[1].GetString();

            if (fields[0].GetString() == "SOAP.Port")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_SOAP_PORT])
                    m_int_configs[CONFIG_SOAP_PORT] = fields[1].GetUInt32();

            ++count;
        }
        while (c_14_console->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u console and remote settings", count);
    }

    sLog.outConfig(" ~~~~~~~~== Console and Remote Settings ==~~~~~~~~ Count(%u)", count);
    sLog.outConfig("Console.Enable is set to ------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_CONSOLE_ENABLED]));
    sLog.outConfig("Ra.Enable is set to ------------------------------------ %s", sc.ToString(m_bool_configs[CONFIG_RA_ENABLE]));
    sLog.outConfig("RA.IP is set to ---------------------------------------- %s", sc.StringEmpty(string_ra_ip.c_str()));
    sLog.outConfig("RA.MinLevel is set to ---------------------------------- %u", m_int_configs[CONFIG_RA_MIN_LEVEL]);
    sLog.outConfig("Ra.Port is set to -------------------------------------- %u", m_int_configs[CONFIG_RA_PORT]);
    sLog.outConfig("SOAP.Enabled is set to --------------------------------- %s", sc.ToString(m_bool_configs[CONFIG_SOAP_ENABLED]));
    sLog.outConfig("SOAP.IP is set to -------------------------------------- %s", sc.StringEmpty(string_soap_ip.c_str()));
    sLog.outConfig("SOAP.Port is set to ------------------------------------ %u", m_int_configs[CONFIG_SOAP_PORT]);

    /// - custom server option configs begin
    std::string s_playerStart                                   = "";    // Get string for new logins (newly created characters)
    m_int_configs[CONFIG_TRADE_LEVEL_REQ]                       = 1;
    m_int_configs[CONFIG_TICKET_LEVEL_REQ]                      = 1;
    m_int_configs[CONFIG_AUCTION_LEVEL_REQ]                     = 1;
    m_int_configs[CONFIG_MAIL_LEVEL_REQ]                        = 1;
    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_ACCOUNTS]              = true;
    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT]      = false;
    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL]   = false;
    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP]     = false;
    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD]     = false;
    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION]   = false;
    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL]      = false;
    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST]              = false;
    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND]            = false;
    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_TRADE]                 = false;
    m_int_configs[CONFIG_CHARDELETE_METHOD]                     = 0;
    m_int_configs[CONFIG_CHARDELETE_MIN_LEVEL]                  = 0;
    m_int_configs[CONFIG_CHARDELETE_KEEP_DAYS]                  = 30;
    m_bool_configs[CONFIG_BG_START_MUSIC]                       = false;
    m_bool_configs[CONFIG_START_ALL_SPELLS]                     = false;
    m_int_configs[CONFIG_HONOR_AFTER_DUEL]                      = 0;
    m_bool_configs[CONFIG_START_ALL_EXPLORED]                   = false;
    m_bool_configs[CONFIG_START_ALL_REP]                        = false;
    m_bool_configs[CONFIG_ALWAYS_MAXSKILL]                      = false;
    m_bool_configs[CONFIG_PVP_TOKEN_ENABLE]                     = false;
    m_int_configs[CONFIG_PVP_TOKEN_MAP_TYPE]                    = 4;
    m_int_configs[CONFIG_PVP_TOKEN_ID]                          = 29434;
    m_int_configs[CONFIG_PVP_TOKEN_COUNT]                       = 1;
    m_bool_configs[CONFIG_NO_RESET_TALENT_COST]                 = false;
    m_bool_configs[CONFIG_SHOW_KICK_IN_WORLD]                   = false;
    m_bool_configs[CONFIG_TALENTS_INSPECTING]                   = true;
    m_bool_configs[CONFIG_GUILD_ALLOW_MULTIPLE_GUILD_MASTER]    = false;

    if (c_15_custom_server_options)                                                
    {
        sLog.outString("Loading custom server options...");
        barGoLink bar(c_15_custom_server_options->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_15_custom_server_options->Fetch();

            if (fields[0].GetString() == "PlayerStart.String")
                if (fields[1].GetString() != s_playerStart.c_str())
                    s_playerStart = fields[1].GetString();

            if (fields[0].GetString() == "LevelReq.Trade")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_TRADE_LEVEL_REQ])
                    m_int_configs[CONFIG_TRADE_LEVEL_REQ] = fields[1].GetUInt32();

            if (fields[0].GetString() == "LevelReq.Ticket")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_TICKET_LEVEL_REQ])
                    m_int_configs[CONFIG_TICKET_LEVEL_REQ] = fields[1].GetUInt32();

            if (fields[0].GetString() == "LevelReq.Auction")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_AUCTION_LEVEL_REQ])
                    m_int_configs[CONFIG_AUCTION_LEVEL_REQ] = fields[1].GetUInt32();

            if (fields[0].GetString() == "LevelReq.Mail")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_MAIL_LEVEL_REQ])
                    m_int_configs[CONFIG_MAIL_LEVEL_REQ] = fields[1].GetUInt32();

            if (fields[0].GetString() == "AllowTwoSide.Accounts")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_ACCOUNTS] = false;

            if (fields[0].GetString() == "AllowTwoSide.Interaction.Chat")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT] = true;

            if (fields[0].GetString() == "AllowTwoSide.Interaction.Channel")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL] = true;

            if (fields[0].GetString() == "AllowTwoSide.Interaction.Group")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP] = true;

            if (fields[0].GetString() == "AllowTwoSide.Interaction.Guild")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD] = true;

            if (fields[0].GetString() == "AllowTwoSide.Interaction.Auction")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION] = true;

            if (fields[0].GetString() == "AllowTwoSide.Interaction.Mail")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL] = true;

            if (fields[0].GetString() == "AllowTwoSide.WhoList")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST] = true;

            if (fields[0].GetString() == "AllowTwoSide.AddFriend")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND] = true;

            if (fields[0].GetString() == "AllowTwoSide.Trade")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALLOW_TWO_SIDE_TRADE] = true;

            if (fields[0].GetString() == "CharDelete.Method")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHARDELETE_METHOD])
                    m_int_configs[CONFIG_CHARDELETE_METHOD] = fields[1].GetUInt32();

            if (fields[0].GetString() == "CharDelete.MinLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHARDELETE_MIN_LEVEL])
                    m_int_configs[CONFIG_CHARDELETE_MIN_LEVEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "CharDelete.KeepDays")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_CHARDELETE_KEEP_DAYS])
                    m_int_configs[CONFIG_CHARDELETE_KEEP_DAYS] = fields[1].GetUInt32();

            if (fields[0].GetString() == "MusicInBattleground")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_BG_START_MUSIC] = true;

            if (fields[0].GetString() == "PlayerStart.AllSpells")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_START_ALL_SPELLS] = true;

            if (fields[0].GetString() == "HonorPointsAfterDuel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_HONOR_AFTER_DUEL])
                    m_int_configs[CONFIG_HONOR_AFTER_DUEL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "PlayerStart.MapsExplored")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_START_ALL_EXPLORED] = true;

            if (fields[0].GetString() == "PlayerStart.AllReputation")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_START_ALL_REP] = true;

            if (fields[0].GetString() == "AlwaysMaxWeaponSkill")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ALWAYS_MAXSKILL] = true;

            if (fields[0].GetString() == "PvPToken.Enable")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_PVP_TOKEN_ENABLE] = true;

            if (fields[0].GetString() == "PvPToken.MapAllowType")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_PVP_TOKEN_MAP_TYPE])
                    m_int_configs[CONFIG_PVP_TOKEN_MAP_TYPE] = fields[1].GetUInt32();

            if (fields[0].GetString() == "PvPToken.ItemID")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_PVP_TOKEN_ID])
                    m_int_configs[CONFIG_PVP_TOKEN_ID] = fields[1].GetUInt32();

            if (fields[0].GetString() == "PvPToken.ItemCount")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_PVP_TOKEN_COUNT])
                    m_int_configs[CONFIG_PVP_TOKEN_COUNT] = fields[1].GetUInt32();

            if (fields[0].GetString() == "NoResetTalentsCost")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_NO_RESET_TALENT_COST] = true;

            if (fields[0].GetString() == "ShowKickInWorld")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_SHOW_KICK_IN_WORLD] = true;

            if (fields[0].GetString() == "TalentsInspecting")
                if (!fields[1].GetBool())
                    m_bool_configs[CONFIG_TALENTS_INSPECTING] = false;

            if (fields[0].GetString() == "Guild.AllowMultipleGuildMaster")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_GUILD_ALLOW_MULTIPLE_GUILD_MASTER] = true;

            ++count;
        }
        while (c_15_custom_server_options->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u custom server options", count);
    }                                                                   

    SetNewCharString(s_playerStart.c_str());

    if (m_bool_configs[CONFIG_START_ALL_SPELLS])
    {
        sLog.outString("WORLD: WARNING: PlayerStart.AllSpells enabled - may not function as intended!");
    }
    if (m_int_configs[CONFIG_PVP_TOKEN_COUNT] < 1)
    {
        m_int_configs[CONFIG_PVP_TOKEN_COUNT] = 1;
    }

    sLog.outConfig(" ~~~~~~~~~~== Custom Server Settings ==~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("AllowTwoSide.Accounts is set to ------------------------ %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_TWO_SIDE_ACCOUNTS]));
    sLog.outConfig("AllowTwoSide.AddFriend is set to ----------------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND]));
    sLog.outConfig("AllowTwoSide.Interaction.Auction is set to ------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION]));
    sLog.outConfig("AllowTwoSide.Interaction.Channel is set to ------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL]));
    sLog.outConfig("AllowTwoSide.Interaction.Chat is set to ---------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT]));
    sLog.outConfig("AllowTwoSide.Interaction.Group is set to --------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP]));
    sLog.outConfig("AllowTwoSide.Interaction.Guild is set to --------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD]));
    sLog.outConfig("AllowTwoSide.Interaction.Mail is set to ---------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_TWO_SIDE_INTERACTION_MAIL]));
    sLog.outConfig("AllowTwoSide.Trade is set to --------------------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_TWO_SIDE_TRADE]));
    sLog.outConfig("AllowTwoSide.WhoList is set to ------------------------- %s", sc.ToString(m_bool_configs[CONFIG_ALLOW_TWO_SIDE_WHO_LIST]));
    sLog.outConfig("AlwaysMaxWeaponSkill is set to ------------------------- %s", sc.ToString(m_bool_configs[CONFIG_ALWAYS_MAXSKILL]));
    sLog.outConfig("CharDelete.KeepDays is set to -------------------------- %u", m_int_configs[CONFIG_CHARDELETE_KEEP_DAYS]);
    sLog.outConfig("CharDelete.Method is set to ---------------------------- %u", m_int_configs[CONFIG_CHARDELETE_METHOD]);
    sLog.outConfig("CharDelete.MinLevel is set to -------------------------- %u", m_int_configs[CONFIG_CHARDELETE_MIN_LEVEL]);
    sLog.outConfig("Guild.AllowMultipleGuildMaster is set to --------------- %s", sc.ToString(m_bool_configs[CONFIG_GUILD_ALLOW_MULTIPLE_GUILD_MASTER]));
    sLog.outConfig("HonorPointsAfterDuel is set to ------------------------- %u", m_int_configs[CONFIG_HONOR_AFTER_DUEL]);
    sLog.outConfig("LevelReq.Auction is set to ----------------------------- %u", m_int_configs[CONFIG_AUCTION_LEVEL_REQ]);
    sLog.outConfig("LevelReq.Mail is set to -------------------------------- %u", m_int_configs[CONFIG_MAIL_LEVEL_REQ]);
    sLog.outConfig("LevelReq.Ticket is set to ------------------------------ %u", m_int_configs[CONFIG_TICKET_LEVEL_REQ]);
    sLog.outConfig("LevelReq.Trade is set to ------------------------------- %u", m_int_configs[CONFIG_TRADE_LEVEL_REQ]);
    sLog.outConfig("MusicInBattleground is set to -------------------------- %s", sc.ToString(m_bool_configs[CONFIG_BG_START_MUSIC]));
    sLog.outConfig("NoResetTalentsCost is set to --------------------------- %s", sc.ToString(m_bool_configs[CONFIG_NO_RESET_TALENT_COST]));
    sLog.outConfig("PlayerStart.AllReputation is set to -------------------- %s", sc.ToString(m_bool_configs[CONFIG_START_ALL_REP]));
    sLog.outConfig("PlayerStart.AllSpells is set to ------------------------ %s", sc.ToString(m_bool_configs[CONFIG_START_ALL_SPELLS]));
    sLog.outConfig("PlayerStart.MapsExplored is set to --------------------- %s", sc.ToString(m_bool_configs[CONFIG_START_ALL_EXPLORED]));
    sLog.outConfig("PlayerStart.String is set to --------------------------- %s", sc.StringEmpty(s_playerStart.c_str()));
    sLog.outConfig("PvPToken.Enable is set to ------------------------------ %s", sc.ToString(m_bool_configs[CONFIG_PVP_TOKEN_ENABLE]));
    sLog.outConfig("PvPToken.ItemCount is set to --------------------------- %u", m_int_configs[CONFIG_PVP_TOKEN_COUNT]);
    sLog.outConfig("PvPToken.ItemID is set to ------------------------------ %u", m_int_configs[CONFIG_PVP_TOKEN_ID]);
    sLog.outConfig("PvPToken.MapAllowType is set to ------------------------ %u", m_int_configs[CONFIG_PVP_TOKEN_MAP_TYPE]);
    sLog.outConfig("ShowKickInWorld is set to ------------------------------ %s", sc.ToString(m_bool_configs[CONFIG_SHOW_KICK_IN_WORLD]));
    sLog.outConfig("TalentsInspecting is set to ---------------------------- %s", sc.ToString(m_bool_configs[CONFIG_TALENTS_INSPECTING]));

    /// - anticheat configs begin
    m_MvAnticheatEnable                 = false;
    m_MvAnticheatKick                   = false;
    m_MvAnticheatAlarmCount             = 5;
    m_MvAnticheatAlarmPeriod            = 5000;
    m_MvAntiCheatBan                    = 0;
    m_MvAnticheatBanTime                = "1m";
    m_MvAnticheatGmLevel                = 0;
    m_MvAnticheatKill                   = false;
    m_MvAnticheatMaxXYT                 = 0.04f;
    m_MvAnticheatIgnoreAfterTeleport    = 10;

    if (c_16_anticheat_settings)                                                 
    {
        sLog.outString("Loading anticheat settings...");
        barGoLink bar(c_16_anticheat_settings->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_16_anticheat_settings->Fetch();

            if (fields[0].GetString() == "Anticheat.Movement.Enable")
                if (fields[1].GetBool())
                    m_MvAnticheatEnable = true;

            if (fields[0].GetString() == "Anticheat.Movement.Kick")
                if (fields[1].GetBool())
                    m_MvAnticheatKick = true;

            if (fields[0].GetString() == "Anticheat.Movement.AlarmCount")
                if (fields[1].GetUInt32() != m_MvAnticheatAlarmCount)
                    m_MvAnticheatAlarmCount = fields[1].GetUInt32();

            if (fields[0].GetString() == "Anticheat.Movement.AlarmTime")
                if (fields[1].GetUInt32() != m_MvAnticheatAlarmPeriod)
                    m_MvAnticheatAlarmPeriod = fields[1].GetUInt32();

            if (fields[0].GetString() == "Anticheat.Movement.BanType")
                if (fields[1].GetUInt32() != m_MvAntiCheatBan)
                    m_MvAntiCheatBan = fields[1].GetUInt32();

            if (fields[0].GetString() == "Anticheat.Movement.BanTime")
                if (fields[1].GetString() != m_MvAnticheatBanTime)
                    m_MvAnticheatBanTime = fields[1].GetString();

            if (fields[0].GetString() == "Anticheat.Movement.GmLevel")
                if (fields[1].GetUInt32() != m_MvAnticheatGmLevel)
                    m_MvAnticheatGmLevel = fields[1].GetUInt32();

            if (fields[0].GetString() == "Anticheat.Movement.Kill")
                if (fields[1].GetBool())
                    m_MvAnticheatKill = true;

            if (fields[0].GetString() == "Anticheat.Movement.MaxXYT")
                if (fields[1].GetFloat() != m_MvAnticheatMaxXYT)
                    m_MvAnticheatMaxXYT = fields[1].GetFloat();

            if (fields[0].GetString() == "Anticheat.Movement.IgnoreSecAfterTeleport")
                if (fields[1].GetUInt32() != m_MvAnticheatIgnoreAfterTeleport)
                    m_MvAnticheatIgnoreAfterTeleport = fields[1].GetUInt32();

            ++count;
        }
        while (c_16_anticheat_settings->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u anticheat settings", count);
    }                                                                  

    sLog.outConfig(" ~~~~~~~~~~~~== AntiCheat Settings ==~~~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("Anticheat.Movement.AlarmCount is set to ---------------- %u", m_MvAnticheatAlarmCount);
    sLog.outConfig("Anticheat.Movement.AlarmTime is set to ----------------- %u", m_MvAnticheatAlarmPeriod);
    sLog.outConfig("Anticheat.Movement.BanTime is set to ------------------- %s", m_MvAnticheatBanTime.c_str());
    sLog.outConfig("Anticheat.Movement.BanType is set to ------------------- %u", m_MvAntiCheatBan);
    sLog.outConfig("Anticheat.Movement.Enable is set to -------------------- %s", sc.ToString(m_MvAnticheatEnable));
    sLog.outConfig("Anticheat.Movement.GmLevel is set to ------------------- %u", m_MvAnticheatGmLevel);
    sLog.outConfig("Anticheat.Movement.IgnoreSecAfterTeleport is set to ---- %u", m_MvAnticheatIgnoreAfterTeleport);
    sLog.outConfig("Anticheat.Movement.Kick is set to ---------------------- %s", sc.ToString(m_MvAnticheatKick));
    sLog.outConfig("Anticheat.Movement.Kill is set to ---------------------- %s", sc.ToString(m_MvAnticheatKill));
    sLog.outConfig("Anticheat.Movement.MaxXYT is set to -------------------- %f", m_MvAnticheatMaxXYT);

    /// - wintergrasp configs begin
    m_bool_configs[CONFIG_ENABLE_WINTERGRASP] = false;
    m_int_configs[CONFIG_WINTERGRASP_PLR_MAX] = 100;
    m_int_configs[CONFIG_WINTERGRASP_PLR_MIN] = 0;
    m_int_configs[CONFIG_WINTERGRASP_PLR_MIN_LVL] = 77;
    m_int_configs[CONFIG_WINTERGRASP_BATTLETIME] = 30;
    m_int_configs[CONFIG_WINTERGRASP_NOBATTLETIME] = 150;

    if (c_17_wintergrasp_settings)                                              
    {
        sLog.outString("Loading wintergrasp settings...");
        barGoLink bar(c_17_wintergrasp_settings->GetRowCount());
        count = 0;
        do
        {
            bar.step();
            Field *fields = c_17_wintergrasp_settings->Fetch();

            if (fields[0].GetString() == "Wintergrasp.Enable")
                if (fields[1].GetBool())
                    m_bool_configs[CONFIG_ENABLE_WINTERGRASP] = true;

            if (fields[0].GetString() == "Wintergrasp.MaxPlayers")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_WINTERGRASP_PLR_MAX])
                    m_int_configs[CONFIG_WINTERGRASP_PLR_MAX] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Wintergrasp.MinPlayers")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_WINTERGRASP_PLR_MIN])
                    m_int_configs[CONFIG_WINTERGRASP_PLR_MIN] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Wintergrasp.AllowedLevel")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_WINTERGRASP_PLR_MIN_LVL])
                    m_int_configs[CONFIG_WINTERGRASP_PLR_MIN_LVL] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Wintergrasp.BattleTimer")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_WINTERGRASP_BATTLETIME])
                    m_int_configs[CONFIG_WINTERGRASP_BATTLETIME] = fields[1].GetUInt32();

            if (fields[0].GetString() == "Wintergrasp.NoBattleTimer")
                if (fields[1].GetUInt32() != m_int_configs[CONFIG_WINTERGRASP_NOBATTLETIME])
                    m_int_configs[CONFIG_WINTERGRASP_NOBATTLETIME] = fields[1].GetUInt32();

            ++count;
        }
        while (c_17_wintergrasp_settings->NextRow());

        sLog.outString();
        sLog.outString(">> Loaded %u wintergrasp settings", count);
    }                                                               

    sLog.outConfig(" ~~~~~~~~~~~~== Wintergrasp Settings ==~~~~~~~~~~~ Count(%u)", count);
    sLog.outConfig("Wintergrasp.Enable is set to --------------------------- %s", sc.ToString(m_bool_configs[CONFIG_ENABLE_WINTERGRASP]));

    sScriptMgr.OnConfigLoad(reload);
}

/// Initialize the World
void World::SetInitialWorldSettings()
{
    ///- Initialize the random number generator
    srand((unsigned int)time(NULL));

    ///- Initialize config settings
    LoadConfigSettings();

    ///- Initialize Allowed Security Level
    LoadDBAllowedSecurityLevel();

    ///- Init highest guids before any table loading to prevent using not initialized guids in some code.
    sObjectMgr.SetHighestGuids();

    ///- Check the existence of the map files for all races' startup areas.
    if (!MapManager::ExistMapAndVMap(0,-6240.32f, 331.033f)
        || !MapManager::ExistMapAndVMap(0,-8949.95f,-132.493f)
        || !MapManager::ExistMapAndVMap(1,-618.518f,-4251.67f)
        || !MapManager::ExistMapAndVMap(0, 1676.35f, 1677.45f)
        || !MapManager::ExistMapAndVMap(1, 10311.3f, 832.463f)
        || !MapManager::ExistMapAndVMap(1,-2917.58f,-257.98f)
        || (m_int_configs[CONFIG_EXPANSION] && (
           !MapManager::ExistMapAndVMap(530,10349.6f,-6357.29f) 
        || !MapManager::ExistMapAndVMap(530,-3961.64f,-13931.2f))))
    {
        sLog.outError("Correct *.map files not found in path '%smaps' or *.vmtree/*.vmtile files in '%svmaps'. Please place *.map/*.vmtree/*.vmtile files in appropriate directories or correct the DataDir value in the Config DB file.",m_dataPath.c_str(),m_dataPath.c_str());
        exit(1);
    }

    sLog.outString("WORLD: VMap support included. LineOfSight: %s, getHeight: %s, indoorCheck: %s PetLOS: %s", 
        sc.ToString(getBoolConfig(CONFIG_VMAP_ENABLE_LOS)), sc.ToString(getBoolConfig(CONFIG_VMAP_ENABLE_HEIGHT)), 
        sc.ToString(getBoolConfig(CONFIG_VMAP_ENABLE_INDOOR)), sc.ToString(getBoolConfig(CONFIG_VMAP_ENABLE_PET_LOS)));

    ///- Loading strings. Getting no records means core load has to be canceled because no error message can be output.
    sLog.outString();
    sLog.outString("Loading Core strings...");
    if (!sObjectMgr.LoadCoreStrings())
        exit(1);                                            // Error message displayed in function already

    ///- Update the realm entry in the database with the realm type from the config file
    // No SQL injection as values are treated as integers
    // not send custom type REALM_FFA_PVP to realm list
    uint32 server_type;
    if (IsFFAPvPRealm())
        server_type = REALM_TYPE_PVP;
    else
        server_type = getIntConfig(CONFIG_GAME_TYPE);
    uint32 realm_zone = getIntConfig(CONFIG_REALM_ZONE);
    LoginDatabase.PExecute("UPDATE realmlist SET icon = %u, timezone = %u WHERE id = '%d'", server_type, realm_zone, realmID);
    LoginDatabase.PExecute("DELETE FROM uptime WHERE realmid = '%u';", realmID);
    ///- Remove the bones (they should not exist in DB though) and old corpses after a restart
    CharacterDatabase.PExecute("DELETE FROM corpse WHERE corpse_type = '0' OR time < (UNIX_TIMESTAMP()-'%u')", 3 * DAY);

    ///- Load the DBC files
    sLog.outString("Initialize data stores...");
    LoadDBCStores(m_dataPath);
    DetectDBCLang();

    sLog.outString("Loading Script Names...");
    sObjectMgr.LoadScriptNames();

    sLog.outString("Loading Instance Template...");
    sObjectMgr.LoadInstanceTemplate();

    sLog.outString("Loading SkillLineAbilityMultiMap Data...");
    sSpellMgr.LoadSkillLineAbilityMap();

    ///- Clean up and pack instances
    sLog.outString("Cleaning up instances...");
    sInstanceSaveMgr.CleanupInstances();                // must be called before `creature_respawn`/`gameobject_respawn` tables

    sLog.outString("Packing instances...");
    sInstanceSaveMgr.PackInstances();

    sLog.outString("Loading Localization strings...");
    sObjectMgr.LoadCreatureLocales();
    sObjectMgr.LoadGameObjectLocales();
    sObjectMgr.LoadItemLocales();
    sObjectMgr.LoadItemSetNameLocales();
    sObjectMgr.LoadQuestLocales();
    sObjectMgr.LoadNpcTextLocales();
    sObjectMgr.LoadPageTextLocales();
    sObjectMgr.LoadGossipMenuItemsLocales();
    sObjectMgr.LoadPointOfInterestLocales();
    sObjectMgr.SetDBCLocaleIndex(GetDefaultDbcLocale());        // Get once for all the locale index of DBC language (console/broadcasts)
    sLog.outString(">>> Localization strings loaded");
    sLog.outString();

    sLog.outString("Loading Page Texts...");
    sObjectMgr.LoadPageTexts();

    sLog.outString("Loading Game Object Templates...");     // must be after LoadPageTexts
    sObjectMgr.LoadGameobjectInfo();

    sLog.outString("Loading Spell Rank Data...");
    sSpellMgr.LoadSpellRanks();

    sLog.outString("Loading Spell Required Data...");
    sSpellMgr.LoadSpellRequired();

    sLog.outString("Loading Spell Group types...");
    sSpellMgr.LoadSpellGroups();

    sLog.outString("Loading Spell Learn Skills...");
    sSpellMgr.LoadSpellLearnSkills();                        // must be after LoadSpellRanks

    sLog.outString("Loading Spell Learn Spells...");
    sSpellMgr.LoadSpellLearnSpells();

    sLog.outString("Loading Spell Proc Event conditions...");
    sSpellMgr.LoadSpellProcEvents();

    sLog.outString("Loading Spell Bonus Data...");
    sSpellMgr.LoadSpellBonusess();

    sLog.outString("Loading Aggro Spells Definitions...");
    sSpellMgr.LoadSpellThreats();

    sLog.outString("Loading Spell Group Stack Rules...");
    sSpellMgr.LoadSpellGroupStackRules();

    sLog.outString("Loading NPC Texts...");
    sObjectMgr.LoadGossipText();

    sLog.outString("Loading Enchant Spells Proc datas...");
    sSpellMgr.LoadSpellEnchantProcData();

    sLog.outString("Loading Item Random Enchantments Table...");
    LoadRandomEnchantmentsTable();

    sLog.outString("Loading Disables");
    sDisableMgr.LoadDisables();                             // must be before loading quests and items

    sLog.outString("Loading Items...");                     // must be after LoadRandomEnchantmentsTable and LoadPageTexts
    sObjectMgr.LoadItemPrototypes();

    sLog.outString("Loading Item set names...");            // must be after LoadItemPrototypes
    sObjectMgr.LoadItemSetNames();

    sLog.outString("Loading Creature Model Based Info Data...");
    sObjectMgr.LoadCreatureModelInfo();

    sLog.outString("Loading Equipment templates...");
    sObjectMgr.LoadEquipmentTemplates();

    sLog.outString("Loading Creature templates...");
    sObjectMgr.LoadCreatureTemplates();

    sLog.outString("Loading Vehicle scaling information...");
    sObjectMgr.LoadVehicleScaling();

    sLog.outString("Loading Reputation Reward Rates...");
    sObjectMgr.LoadReputationRewardRate();

    sLog.outString("Loading Creature Reputation OnKill Data...");
    sObjectMgr.LoadReputationOnKill();

    sLog.outString( "Loading Reputation Spillover Data..." );
    sObjectMgr.LoadReputationSpilloverTemplate();

    sLog.outString("Loading Points Of Interest Data...");
    sObjectMgr.LoadPointsOfInterest();

    sLog.outString("Loading Creature Base Stats...");
    sObjectMgr.LoadCreatureClassLevelStats();

    sLog.outString("Loading Creature Data...");
    sObjectMgr.LoadCreatures();

    sLog.outString("Loading Creature Linked Respawn...");
    sObjectMgr.LoadCreatureLinkedRespawn();                     // must be after LoadCreatures()

    sLog.outString("Loading pet levelup spells...");
    sSpellMgr.LoadPetLevelupSpellMap();

    sLog.outString("Loading pet default spell additional to levelup spells...");
    sSpellMgr.LoadPetDefaultSpells();

    sLog.outString("Loading Creature Template Addon Data...");
    sObjectMgr.LoadCreatureAddons();                            // must be after LoadCreatureTemplates() and LoadCreatures()

    sLog.outString("Loading Vehicle Accessories...");
    sObjectMgr.LoadVehicleAccessories();                        // must be after LoadCreatureTemplates()

    sLog.outString("Loading Creature Respawn Data...");         // must be after PackInstances()
    sObjectMgr.LoadCreatureRespawnTimes();

    sLog.outString("Loading Gameobject Data...");
    sObjectMgr.LoadGameobjects();

    sLog.outString("Loading Gameobject Respawn Data...");       // must be after PackInstances()
    sObjectMgr.LoadGameobjectRespawnTimes();

    sLog.outString("Loading Objects Pooling Data...");
    sPoolMgr.LoadFromDB();

    sLog.outString("Loading Weather Data...");
    sWeatherMgr.LoadWeatherData();

    sLog.outString("Loading Quests...");
    sObjectMgr.LoadQuests();                                    // must be loaded after DBCs, creature_template, item_template, gameobject tables

    sLog.outString("Checking Quest Disables");
    sDisableMgr.CheckQuestDisables();                           // must be after loading quests

    sLog.outString("Loading Quest POI");
    sObjectMgr.LoadQuestPOI();

    sLog.outString("Loading Quests Relations...");
    sObjectMgr.LoadQuestRelations();                            // must be after quest load

    sLog.outString("Loading Quest Pooling Data...");
    sPoolMgr.LoadQuestPools();

    sLog.outString("Loading Game Event Data...");               // must be after loading pools fully
    sGameEventMgr.LoadFromDB();

    sLog.outString("Loading Dungeon boss data...");
    sLFGMgr.LoadDungeonEncounters();

    sLog.outString("Loading LFG rewards...");
    sLFGMgr.LoadRewards();

    sLog.outString("Loading UNIT_NPC_FLAG_SPELLCLICK Data...");
    sObjectMgr.LoadNPCSpellClickSpells();

    sLog.outString("Loading SpellArea Data...");            // must be after quest load
    sSpellMgr.LoadSpellAreas();

    sLog.outString("Loading AreaTrigger definitions...");
    sObjectMgr.LoadAreaTriggerTeleports();

    sLog.outString("Loading Access Requirements...");
    sObjectMgr.LoadAccessRequirements();                        // must be after item template load

    sLog.outString("Loading Quest Area Triggers...");
    sObjectMgr.LoadQuestAreaTriggers();                         // must be after LoadQuests

    sLog.outString("Loading Tavern Area Triggers...");
    sObjectMgr.LoadTavernAreaTriggers();

    sLog.outString("Loading AreaTrigger script names...");
    sObjectMgr.LoadAreaTriggerScripts();

    sLog.outString("Loading Graveyard-zone links...");
    sObjectMgr.LoadGraveyardZones();

    sLog.outString("Loading spell pet auras...");
    sSpellMgr.LoadSpellPetAuras();

    sLog.outString("Loading spell extra attributes...");
    sSpellMgr.LoadSpellCustomAttr();

    sLog.outString("Loading Spell target coordinates...");
    sSpellMgr.LoadSpellTargetPositions();

    sLog.outString("Loading enchant custom attributes...");
    sSpellMgr.LoadEnchantCustomAttr();

    sLog.outString("Loading linked spells...");
    sSpellMgr.LoadSpellLinked();

    sLog.outString("Loading Player Create Data...");
    sObjectMgr.LoadPlayerInfo();

    sLog.outString("Loading Exploration BaseXP Data...");
    sObjectMgr.LoadExplorationBaseXP();

    sLog.outString("Loading Pet Name Parts...");
    sObjectMgr.LoadPetNames();

    CharacterDatabaseCleaner::CleanDatabase();

    sLog.outString("Loading the max pet number...");
    sObjectMgr.LoadPetNumber();

    sLog.outString("Loading pet level stats...");
    sObjectMgr.LoadPetLevelInfo();

    sLog.outString("Loading Player Corpses...");
    sObjectMgr.LoadCorpses();

    sLog.outString("Loading Player level dependent mail rewards...");
    sObjectMgr.LoadMailLevelRewards();

    // Loot tables
    LoadLootTables();

    sLog.outString("Loading Skill Discovery Table...");
    LoadSkillDiscoveryTable();

    sLog.outString("Loading Skill Extra Item Table...");
    LoadSkillExtraItemTable();

    sLog.outString("Loading Skill Fishing base level requirements...");
    sObjectMgr.LoadFishingBaseSkillLevel();

    sLog.outString("Loading Achievements...");
    sAchievementMgr.LoadAchievementReferenceList();
    sLog.outString("Loading Achievement Criteria Lists...");
    sAchievementMgr.LoadAchievementCriteriaList();
    sLog.outString("Loading Achievement Criteria Data...");
    sAchievementMgr.LoadAchievementCriteriaData();
    sLog.outString("Loading Achievement Rewards...");
    sAchievementMgr.LoadRewards();
    sLog.outString("Loading Achievement Reward Locales...");
    sAchievementMgr.LoadRewardLocales();
    sLog.outString("Loading Completed Achievements...");
    sAchievementMgr.LoadCompletedAchievements();

    ///- Load dynamic data tables from the database
    sLog.outString("Loading Item Auctions...");
    sAuctionMgr.LoadAuctionItems();

    sLog.outString("Loading Auctions...");
    sAuctionMgr.LoadAuctions();

    sLog.outString("***** GUILDS *****");
    sObjectMgr.LoadGuilds();

    sLog.outString("Loading ArenaTeams...");
    sObjectMgr.LoadArenaTeams();

    sLog.outString("Loading Groups...");
    sObjectMgr.LoadGroups();

    sLog.outString("Loading ReservedNames...");
    sObjectMgr.LoadReservedPlayersNames();

    sLog.outString("Loading GameObjects for quests...");
    sObjectMgr.LoadGameObjectForQuests();

    sLog.outString("Loading BattleMasters...");
    sBattlegroundMgr.LoadBattleMastersEntry();

    sLog.outString("Loading GameTeleports...");
    sObjectMgr.LoadGameTele();

    sLog.outString("Loading Npc Text Id...");
    sObjectMgr.LoadNpcTextId();                                 // must be after load Creature and NpcText

    sObjectMgr.LoadGossipScripts();                             // must be before gossip menu options

    sLog.outString("Loading Gossip menu...");
    sObjectMgr.LoadGossipMenu();

    sLog.outString("Loading Gossip menu options...");
    sObjectMgr.LoadGossipMenuItems();

    sLog.outString("Loading Vendors...");
    sObjectMgr.LoadVendors();                                   // must be after load CreatureTemplate and ItemTemplate

    sLog.outString("Loading Trainers...");
    sObjectMgr.LoadTrainerSpell();                              // must be after load CreatureTemplate

    sLog.outString("Loading Waypoints...");
    sWaypointMgr->Load();

    sLog.outString("Loading SmartAI Waypoints...");
    sSmartWaypointMgr.LoadFromDB();

    sLog.outString("Loading Creature Formations...");
    formation_mgr.LoadCreatureFormations();

    sLog.outString("Loading Conditions...");
    sConditionMgr.LoadConditions();

    sLog.outString("Loading faction change achievement pairs...");
    sObjectMgr.LoadFactionChangeAchievements();

    sLog.outString("Loading faction change spell pairs...");
    sObjectMgr.LoadFactionChangeSpells();

    sLog.outString("Loading faction change item pairs...");
    sObjectMgr.LoadFactionChangeItems();

    sLog.outString("Loading faction change reputation pairs...");
    sObjectMgr.LoadFactionChangeReputations();

    sLog.outString("Loading GM tickets...");
    sTicketMgr.LoadGMTickets();

    sLog.outString("Loading GM surveys...");
    sTicketMgr.LoadGMSurveys();

    sLog.outString("Loading client addons...");
    sAddonMgr.LoadFromDB();

    ///- Handle outdated emails (delete/return)
    sLog.outString("Returning old mails...");
    sObjectMgr.ReturnOrDeleteOldMails(false);

    sLog.outString("Loading Autobroadcasts...");
    LoadAutobroadcasts();

    ///- Load and initialize scripts
    sLog.outString("Loading Scripts...");
    sLog.outString();
    sObjectMgr.LoadQuestStartScripts();                         // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
    sObjectMgr.LoadQuestEndScripts();                           // must be after load Creature/Gameobject(Template/Data) and QuestTemplate
    sObjectMgr.LoadSpellScripts();                              // must be after load Creature/Gameobject(Template/Data)
    sObjectMgr.LoadGameObjectScripts();                         // must be after load Creature/Gameobject(Template/Data)
    sObjectMgr.LoadEventScripts();                              // must be after load Creature/Gameobject(Template/Data)
    sObjectMgr.LoadWaypointScripts();
    sLog.outString(">>> Scripts loaded");
    sLog.outString();

    sLog.outString("Loading Scripts text locales...");      // must be after Load*Scripts calls
    sObjectMgr.LoadDbScriptStrings();

    sLog.outString("Loading CreatureEventAI Texts...");
    sEventAIMgr.LoadCreatureEventAI_Texts();

    sLog.outString("Loading CreatureEventAI Summons...");
    sEventAIMgr.LoadCreatureEventAI_Summons();

    sLog.outString("Loading CreatureEventAI Scripts...");
    sEventAIMgr.LoadCreatureEventAI_Scripts();

    sLog.outString("Loading spell script names...");
    sObjectMgr.LoadSpellScriptNames();

    sLog.outString("Loading Creature Texts...");
    sCreatureTextMgr.LoadCreatureTexts();

    sLog.outString("Initializing Scripts...");
    sScriptMgr.Initialize();

    sLog.outString("Validating spell scripts...");
    sObjectMgr.ValidateSpellScripts();

    sLog.outString("Loading SmartAI scripts...");
    sSmartScriptMgr.LoadSmartAIFromDB();

    ///- Initialize game time and timers
    sLog.outDebug("DEBUG:: Initialize game time and timers");
    m_gameTime = time(NULL);
    m_startTime = m_gameTime;

    tm local;
    time_t curr;
    time(&curr);
    local = *(localtime(&curr));                              // dereference and assign
    char isoDate[128];
    sprintf(isoDate, "%04d-%02d-%02d %02d:%02d:%02d",
        local.tm_year+1900, local.tm_mon+1, local.tm_mday, local.tm_hour, local.tm_min, local.tm_sec);

    LoginDatabase.PExecute("INSERT INTO uptime (realmid, starttime, startstring, uptime, revision) VALUES('%u', " UI64FMTD ", '%s', 0, '%s')",
        realmID, uint64(m_startTime), isoDate, _FULLVERSION);

    m_timers[WUPDATE_OBJECTS].SetInterval(IN_MILLISECONDS/2);
    m_timers[WUPDATE_SESSIONS].SetInterval(0);
    m_timers[WUPDATE_WEATHERS].SetInterval(1*IN_MILLISECONDS);
    m_timers[WUPDATE_AUCTIONS].SetInterval(MINUTE*IN_MILLISECONDS);
    m_timers[WUPDATE_UPTIME].SetInterval(m_int_configs[CONFIG_UPTIME_UPDATE]*MINUTE*IN_MILLISECONDS); //Update "uptime" table based on configuration entry in minutes.
    m_timers[WUPDATE_CORPSES].SetInterval(20 * MINUTE * IN_MILLISECONDS); //erase corpses every 20 minutes
    m_timers[WUPDATE_CLEANDB].SetInterval(m_int_configs[CONFIG_LOGDB_CLEARINTERVAL]*MINUTE*IN_MILLISECONDS); // clean logs table every 14 days by default
    m_timers[WUPDATE_AUTOBROADCAST].SetInterval(getIntConfig(CONFIG_AUTOBROADCAST_INTERVAL));
    m_timers[WUPDATE_DELETECHARS].SetInterval(DAY*IN_MILLISECONDS); // check for chars to delete every day
    m_timers[WUPDATE_PINGDB].SetInterval(getIntConfig(CONFIG_DB_PING_INTERVAL)*MINUTE*IN_MILLISECONDS); // Mysql ping time in seconds

    //to set mailtimer to return mails every day between 4 and 5 am
    //mailtimer is increased when updating auctions
    //one second is 1000 -(tested on win system)
    //TODO: Get rid of magic numbers
    mail_timer = ((((localtime(&m_gameTime)->tm_hour + 20) % 24)* HOUR * IN_MILLISECONDS) / m_timers[WUPDATE_AUCTIONS].GetInterval()); //1440
    mail_timer_expires = ((DAY * IN_MILLISECONDS) / (m_timers[WUPDATE_AUCTIONS].GetInterval()));
    sLog.outDebug("Mail timer set to: " UI64FMTD ", mail return is called every " UI64FMTD " minutes", uint64(mail_timer), uint64(mail_timer_expires));

    ///- Initilize static helper structures
    AIRegistry::Initialize();
    Player::InitVisibleBits();

    ///- Initialize MapManager
    sLog.outString("Starting Map System");
    sMapMgr.Initialize();

    sLog.outString("Starting Game Event system...");
    uint32 nextGameEvent = sGameEventMgr.Initialize();
    m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);    //depend on next event

    // Delete all characters which have been deleted X days before
    Player::DeleteOldCharacters();

    // Delete all custom channels which haven't been used for PreserveCustomChannelDuration days.
    Channel::CleanOldChannelsInDB();

    sLog.outString("Starting Arena Season...");
    sGameEventMgr.StartArenaSeason();

    sTicketMgr.Initialize();

    sLog.outString("Loading World States...");              // must be loaded before battleground and outdoor PvP
    LoadWorldStates();

    ///- Initialize Battlegrounds
    sLog.outString("Starting Battleground System");
    sBattlegroundMgr.CreateInitialBattlegrounds();
    sBattlegroundMgr.InitAutomaticArenaPointDistribution();

    ///- Initialize outdoor pvp
    sLog.outString("Starting Outdoor PvP System");
    sOutdoorPvPMgr.InitOutdoorPvP();

    ///- Initialize Battlefield
    sLog.outString("Starting Battlefield System");
    sBattlefieldMgr.InitBattlefield();

    sLog.outString("Loading Transports...");
    sMapMgr.LoadTransports();

    sLog.outString("Loading Transport NPCs...");
    sMapMgr.LoadTransportNPCs();

    sLog.outString("Deleting expired bans...");
    LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate <= UNIX_TIMESTAMP() AND unbandate<>bandate");

    sLog.outString("Starting objects Pooling system...");
    sPoolMgr.Initialize();

    sLog.outString("Calculate next daily quest reset time...");
    InitDailyQuestResetTime();

    sLog.outString("Calculate next weekly quest reset time..." );
    InitWeeklyQuestResetTime();

    sLog.outString("Calculate random battleground reset time..." );
    InitRandomBGResetTime();

    sLog.outString("Initialize AuctionHouseBot...");
    auctionbot.Initialize();

    // possibly enable db logging; avoid massive startup spam by doing it here.
    if (sLog.GetLogDBLater())
    {
        sLog.outString("Enabling database logging...");
        sLog.SetLogDBLater(false);
        sLog.SetLogDB(true);
    }
    else
        sLog.SetLogDB(false);

    sLog.outString("WORLD: World initialized");
}

void World::DetectDBCLang()
{
    uint32 m_lang_confid = getIntConfig(CONFIG_DBC_LOCALE);

    if (m_lang_confid != 255 && m_lang_confid >= TOTAL_LOCALES)
    {
        sLog.outError("Incorrect DBC.Locale! Must be >= 0 and < %d (set to 0)", TOTAL_LOCALES);
        m_lang_confid = LOCALE_enUS;
    }

    ChrRacesEntry const* race = sChrRacesStore.LookupEntry(1);

    std::string availableLocalsStr;

    uint8 default_locale = TOTAL_LOCALES;
    for (uint8 i = default_locale-1; i < TOTAL_LOCALES; --i)  // -1 will be 255 due to uint8
    {
        if (strlen(race->name[i]) > 0)                     // check by race names
        {
            default_locale = i;
            m_availableDbcLocaleMask |= (1 << i);
            availableLocalsStr += localeNames[i];
            availableLocalsStr += " ";
        }
    }

    if (default_locale != m_lang_confid && m_lang_confid < TOTAL_LOCALES && (m_availableDbcLocaleMask & (1 << m_lang_confid)))
    {
        default_locale = m_lang_confid;
    }

    if (default_locale >= TOTAL_LOCALES)
    {
        sLog.outError("Unable to determine your DBC Locale! (corrupt DBC?)");
        exit(1);
    }

    m_defaultDbcLocale = LocaleConstant(default_locale);

    sLog.outString("Using %s DBC Locale as default. All available DBC locales: %s", localeNames[m_defaultDbcLocale], availableLocalsStr.empty() ? "<none>" : availableLocalsStr.c_str());
    sLog.outString();
}

void World::RecordTimeDiff(const char *text, ...)
{
    if (m_updateTimeCount != 1)
        return;
    if (!text)
    {
        m_currentTime = getMSTime();
        return;
    }

    uint32 thisTime = getMSTime();
    uint32 diff = getMSTimeDiff(m_currentTime, thisTime);

    if (diff > m_int_configs[CONFIG_MIN_LOG_UPDATE])
    {
        va_list ap;
        char str[256];
        va_start(ap, text);
        vsnprintf(str, 256, text, ap);
        va_end(ap);
        sLog.outDetail("Difftime %s: %u.", str, diff);
    }

    m_currentTime = thisTime;
}

void World::LoadAutobroadcasts()
{
    m_Autobroadcasts.clear();
    QueryResult result = WorldDatabase.Query("SELECT text FROM autobroadcast");

    if (!result)
    {
        barGoLink bar(1);
        bar.step();

        sLog.outString();
        sLog.outString(">> Loaded 0 autobroadcasts definitions");
        return;
    }

    barGoLink bar(result->GetRowCount());

    uint32 count = 0;
    do
    {
        bar.step();

        Field *fields = result->Fetch();
        std::string message = fields[0].GetString();

        m_Autobroadcasts.push_back(message);

        count++;
    } while (result->NextRow());

    sLog.outString();
    sLog.outString(">> Loaded %u autobroadcasts definitions", count);
}

/// Update the World !
void World::Update(uint32 diff)
{
    m_updateTime = diff;

    if (m_int_configs[CONFIG_INTERVAL_LOG_UPDATE] && diff > m_int_configs[CONFIG_MIN_LOG_UPDATE])
    {
        if (m_updateTimeSum > m_int_configs[CONFIG_INTERVAL_LOG_UPDATE])
        {
            sLog.outBasic("Update time diff: %u. Players online: %u.", m_updateTimeSum / m_updateTimeCount, GetActiveSessionCount());
            m_updateTimeSum = m_updateTime;
            m_updateTimeCount = 1;
        }
        else
        {
            m_updateTimeSum += m_updateTime;
            ++m_updateTimeCount;
        }
    }

    ///- Update the different timers
    for (int i = 0; i < WUPDATE_COUNT; ++i)
    {
        if (m_timers[i].GetCurrent() >= 0)
            m_timers[i].Update(diff);
        else
            m_timers[i].SetCurrent(0);
    }

    ///- Update the game time and check for shutdown time
    _UpdateGameTime();

    /// Handle daily quests reset time
    if (m_gameTime > m_NextDailyQuestReset)
    {
        ResetDailyQuests();
        m_NextDailyQuestReset += DAY;
    }

    if (m_gameTime > m_NextWeeklyQuestReset)
        ResetWeeklyQuests();

    if (m_gameTime > m_NextRandomBGReset)
        ResetRandomBG();

    /// <ul><li> Handle auctions when the timer has passed
    if (m_timers[WUPDATE_AUCTIONS].Passed())
    {
        auctionbot.Update();
        m_timers[WUPDATE_AUCTIONS].Reset();

        ///- Update mails (return old mails with item, or delete them)
        //(tested... works on win)
        if (++mail_timer > mail_timer_expires)
        {
            mail_timer = 0;
            sObjectMgr.ReturnOrDeleteOldMails(true);
        }

        ///- Handle expired auctions
        sAuctionMgr.Update();
    }

    /// <li> Handle session updates when the timer has passed
    RecordTimeDiff(NULL);
    UpdateSessions(diff);
    RecordTimeDiff("UpdateSessions");

    /// <li> Handle weather updates when the timer has passed
    if (m_timers[WUPDATE_WEATHERS].Passed())
    {
        m_timers[WUPDATE_WEATHERS].Reset();
        sWeatherMgr.Update(uint32(m_timers[WUPDATE_WEATHERS].GetInterval()));
    }

    /// <li> Update uptime table
    if (m_timers[WUPDATE_UPTIME].Passed())
    {
        uint32 tmpDiff = uint32(m_gameTime - m_startTime);
        uint32 maxOnlinePlayers = GetMaxPlayerCount();

        m_timers[WUPDATE_UPTIME].Reset();
        LoginDatabase.PExecute("UPDATE uptime SET uptime = %u, maxplayers = %u WHERE realmid = %u AND starttime = " UI64FMTD, tmpDiff, maxOnlinePlayers, realmID, uint64(m_startTime));
    }

    /// <li> Clean logs table
    if (sWorld.getIntConfig(CONFIG_LOGDB_CLEARTIME) > 0) // if not enabled, ignore the timer
    {
        if (m_timers[WUPDATE_CLEANDB].Passed())
        {
            m_timers[WUPDATE_CLEANDB].Reset();
            LoginDatabase.PExecute("DELETE FROM logs WHERE (time + %u) < "UI64FMTD";",
                sWorld.getIntConfig(CONFIG_LOGDB_CLEARTIME), uint64(time(0)));
        }
    }

    /// <li> Handle all other objects
    ///- Update objects when the timer has passed (maps, transport, creatures,...)
    sMapMgr.Update(diff);                // As interval = 0

    if (sWorld.getBoolConfig(CONFIG_AUTOBROADCAST))
    {
        if (m_timers[WUPDATE_AUTOBROADCAST].Passed())
        {
            m_timers[WUPDATE_AUTOBROADCAST].Reset();
            SendAutoBroadcast();
        }
    }

    sBattlegroundMgr.Update(diff);
    RecordTimeDiff("UpdateBattlegroundMgr");

    sOutdoorPvPMgr.Update(diff);
    RecordTimeDiff("UpdateOutdoorPvPMgr");

    sBattlefieldMgr.Update(diff);
    RecordTimeDiff("BattlefieldMgr");

    ///- Delete all characters which have been deleted X days before
    if (m_timers[WUPDATE_DELETECHARS].Passed())
    {
        m_timers[WUPDATE_DELETECHARS].Reset();
        Player::DeleteOldCharacters();
    }

    sLFGMgr.Update(diff);
    RecordTimeDiff("UpdateLFGMgr");

    // execute callbacks from sql queries that were queued recently
    ProcessQueryCallbacks();
    RecordTimeDiff("ProcessQueryCallbacks");

    ///- Erase corpses once every 20 minutes
    if (m_timers[WUPDATE_CORPSES].Passed())
    {
        m_timers[WUPDATE_CORPSES].Reset();
        sObjectAccessor.RemoveOldCorpses();
    }

    ///- Process Game events when necessary
    if (m_timers[WUPDATE_EVENTS].Passed())
    {
        m_timers[WUPDATE_EVENTS].Reset();                   // to give time for Update() to be processed
        uint32 nextGameEvent = sGameEventMgr.Update();
        m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);
        m_timers[WUPDATE_EVENTS].Reset();
    }

    ///- Ping to keep MySQL connections alive
    if (m_timers[WUPDATE_PINGDB].Passed())
    {
        m_timers[WUPDATE_PINGDB].Reset();
        sLog.outDetail("Ping MySQL to keep connection alive");
        CharacterDatabase.KeepAlive();
        LoginDatabase.KeepAlive();
        WorldDatabase.KeepAlive();
    }

    // update the instance reset times
    sInstanceSaveMgr.Update();

    // And last, but not least handle the issued cli commands
    ProcessCliCommands();

    sScriptMgr.OnWorldUpdate(diff);
}

void World::ForceGameEventUpdate()
{
    m_timers[WUPDATE_EVENTS].Reset();                   // to give time for Update() to be processed
    uint32 nextGameEvent = sGameEventMgr.Update();
    m_timers[WUPDATE_EVENTS].SetInterval(nextGameEvent);
    m_timers[WUPDATE_EVENTS].Reset();
}

/// Send a packet to all players (except self if mentioned)
void World::SendGlobalMessage(WorldPacket *packet, WorldSession *self, uint32 team)
{
    SessionMap::const_iterator itr;
    for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
    {
        if (itr->second &&
            itr->second->GetPlayer() &&
            itr->second->GetPlayer()->IsInWorld() &&
            itr->second != self &&
            (team == 0 || itr->second->GetPlayer()->GetTeam() == team))
        {
            itr->second->SendPacket(packet);
        }
    }
}

/// Send a packet to all GMs (except self if mentioned)
void World::SendGlobalGMMessage(WorldPacket *packet, WorldSession *self, uint32 team)
{
    SessionMap::iterator itr;
    for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
    {
        if (itr->second &&
            itr->second->GetPlayer() &&
            itr->second->GetPlayer()->IsInWorld() &&
            itr->second != self &&
            itr->second->GetSecurity() > SEC_PLAYER &&
            (team == 0 || itr->second->GetPlayer()->GetTeam() == team))
        {
            itr->second->SendPacket(packet);
        }
    }
}

namespace Core
{
    class WorldWorldTextBuilder
    {
    public:
        typedef std::vector<WorldPacket*> WorldPacketList;
        explicit WorldWorldTextBuilder(int32 textId, va_list* args = NULL) : i_textId(textId), i_args(args) { }
        void operator()(WorldPacketList& data_list, LocaleConstant loc_idx)
        {
            char const* text = sObjectMgr.GetCoreString(i_textId,loc_idx);

            if (i_args)
            {
                // we need copy va_list before use or original va_list will corrupted
                va_list ap;
                va_copy(ap, *i_args);

                char str[2048];
                vsnprintf(str, 2048, text, ap);
                va_end(ap);

                do_helper(data_list, &str[0]);
            }
            else
                do_helper(data_list, (char*)text);
        }
    private:
        char* lineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = NULL; return start; }
        void do_helper(WorldPacketList& data_list, char* text)
        {
            char* pos = text;

            while (char* line = lineFromMessage(pos))
            {
                WorldPacket* data = new WorldPacket();

                uint32 lineLength = (line ? strlen(line) : 0) + 1;

                data->Initialize(SMSG_MESSAGECHAT, 100);                // guess size
                *data << uint8(CHAT_MSG_SYSTEM);
                *data << uint32(LANG_UNIVERSAL);
                *data << uint64(0);
                *data << uint32(0);                                     // can be chat msg group or something
                *data << uint64(0);
                *data << uint32(lineLength);
                *data << line;
                *data << uint8(0);

                data_list.push_back(data);
            }
        }

        int32 i_textId;
        va_list* i_args;
    };
}                                                           // namespace Core

/// Send a System Message to all players (except self if mentioned)
void World::SendWorldText(int32 string_id, ...)
{
    va_list ap;
    va_start(ap, string_id);

    Core::WorldWorldTextBuilder wt_builder(string_id, &ap);
    Core::LocalizedPacketListDo<Core::WorldWorldTextBuilder> wt_do(wt_builder);
    for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
    {
        if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld())
            continue;

        wt_do(itr->second->GetPlayer());
    }

    va_end(ap);
}

/// Send a System Message to all GMs (except self if mentioned)
void World::SendGMText(int32 string_id, ...)
{
    va_list ap;
    va_start(ap, string_id);

    Core::WorldWorldTextBuilder wt_builder(string_id, &ap);
    Core::LocalizedPacketListDo<Core::WorldWorldTextBuilder> wt_do(wt_builder);
    for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
    {
        if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld())
            continue;

        if (itr->second->GetSecurity() < SEC_MODERATOR)
            continue;

        wt_do(itr->second->GetPlayer());
    }

    va_end(ap);
}

/// DEPRECATED, only for debug purpose. Send a System Message to all players (except self if mentioned)
void World::SendGlobalText(const char* text, WorldSession *self)
{
    WorldPacket data;

    // need copy to prevent corruption by strtok call in LineFromMessage original string
    char* buf = strdup(text);
    char* pos = buf;

    while (char* line = ChatHandler::LineFromMessage(pos))
    {
        ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, line, NULL);
        SendGlobalMessage(&data, self);
    }

    free(buf);
}

/// Send a packet to all players (or players selected team) in the zone (except self if mentioned)
void World::SendZoneMessage(uint32 zone, WorldPacket *packet, WorldSession *self, uint32 team)
{
    SessionMap::const_iterator itr;
    for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
    {
        if (itr->second &&
            itr->second->GetPlayer() &&
            itr->second->GetPlayer()->IsInWorld() &&
            itr->second->GetPlayer()->GetZoneId() == zone &&
            itr->second != self &&
            (team == 0 || itr->second->GetPlayer()->GetTeam() == team))
        {
            itr->second->SendPacket(packet);
        }
    }
}

/// Send a System Message to all players in the zone (except self if mentioned)
void World::SendZoneText(uint32 zone, const char* text, WorldSession *self, uint32 team)
{
    WorldPacket data;
    ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, NULL, 0, text, NULL);
    SendZoneMessage(zone, &data, self,team);
}

/// Kick (and save) all players
void World::KickAll()
{
    m_QueuedPlayer.clear();                                 // prevent send queue update packet and login queued sessions

    // session not removed at kick and will removed in next update tick
    for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
        itr->second->KickPlayer();
}

/// Kick (and save) all players with security level less `sec`
void World::KickAllLess(AccountTypes sec)
{
    // session not removed at kick and will removed in next update tick
    for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
        if (itr->second->GetSecurity() < sec)
            itr->second->KickPlayer();
}

/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author)
{
    uint32 duration_secs = TimeStringToSecs(duration);
    PreparedQueryResult resultAccounts = PreparedQueryResult(NULL); //used for kicking
    PreparedStatement* stmt = NULL;

    ///- Update the database with ban information
    switch(mode)
    {
    case BAN_IP:
        // No SQL injection with prepared statements
        stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_ACCOUNT_BY_IP);
        stmt->setString(0, nameOrIP);
        resultAccounts = LoginDatabase.Query(stmt);
        stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_IP_BANNED);
        stmt->setString(0, nameOrIP);
        stmt->setUInt32(1, duration_secs);
        stmt->setString(2, author);
        stmt->setString(3, reason);
        LoginDatabase.Execute(stmt);
        break;
    case BAN_ACCOUNT:
        // No SQL injection with prepared statements
        stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_ACCIDBYNAME);
        stmt->setString(0, nameOrIP);
        resultAccounts = LoginDatabase.Query(stmt);
        break;
    case BAN_CHARACTER:
        // No SQL injection with prepared statements
        stmt = CharacterDatabase.GetPreparedStatement(CHAR_GET_ACCOUNT_BY_NAME);
        stmt->setString(0, nameOrIP);
        resultAccounts = CharacterDatabase.Query(stmt);
        break;
    default:
        return BAN_SYNTAX_ERROR;
    }

    if (!resultAccounts)
    {
        if (mode == BAN_IP)
            return BAN_SUCCESS;                             // ip correctly banned but nobody affected (yet)
        else
            return BAN_NOTFOUND;                            // Nobody to ban
    }

    ///- Disconnect all affected players (for IP it can be several)
    SQLTransaction trans = LoginDatabase.BeginTransaction();
    do
    {
        Field* fieldsAccount = resultAccounts->Fetch();
        uint32 account = fieldsAccount->GetUInt32();

        if (mode != BAN_IP)
        {
            // make sure there is only one active ban
            stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_ACCOUNT_NOT_BANNED);
            stmt->setUInt32(0, account);
            trans->Append(stmt);
            // No SQL injection with prepared statements
            stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_ACCOUNT_BANNED);
            stmt->setUInt32(0, account);
            stmt->setUInt32(1, duration_secs);
            stmt->setString(2, author);
            stmt->setString(3, reason);
            trans->Append(stmt);
        }

        if (WorldSession* sess = FindSession(account))
            if (std::string(sess->GetPlayerName()) != author)
                sess->KickPlayer();
    } while (resultAccounts->NextRow());

    LoginDatabase.CommitTransaction(trans);

    return BAN_SUCCESS;
}

/// Remove a ban from an account or IP address
bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
{
    PreparedStatement* stmt = NULL;
    if (mode == BAN_IP)
    {
        stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_IP_NOT_BANNED);
        stmt->setString(0, nameOrIP);
        LoginDatabase.Execute(stmt);
    }
    else
    {
        uint32 account = 0;
        if (mode == BAN_ACCOUNT)
            account = sAccountMgr.GetId(nameOrIP);
        else if (mode == BAN_CHARACTER)
            account = sObjectMgr.GetPlayerAccountIdByPlayerName(nameOrIP);

        if (!account)
            return false;

        //NO SQL injection as account is uint32
        stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_ACCOUNT_NOT_BANNED);
        stmt->setUInt32(0, account);
        LoginDatabase.Execute(stmt);
    }
    return true;
}

/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
BanReturn World::BanCharacter(std::string name, std::string duration, std::string reason, std::string author)
{
    Player *pBanned = sObjectMgr.GetPlayer(name.c_str());
    uint32 guid = 0;

    uint32 duration_secs = TimeStringToSecs(duration);

    /// Pick a player to ban if not online
    if (!pBanned)
    {
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_GET_GUID_BY_NAME);
        stmt->setString(0, name);
        PreparedQueryResult resultCharacter = CharacterDatabase.Query(stmt);

        if (!resultCharacter)
            return BAN_NOTFOUND;                                    // Nobody to ban

        guid = (*resultCharacter)[0].GetUInt32();
    }
    else
        guid = pBanned->GetGUIDLow();

    // make sure there is only one active ban
    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SET_NOT_BANNED);
    stmt->setUInt32(0, guid);
    CharacterDatabase.Execute(stmt);

    stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_BAN);
    stmt->setUInt32(0, guid);
    stmt->setUInt32(1, duration_secs);
    stmt->setString(2, author);
    stmt->setString(3, reason);
    CharacterDatabase.Execute(stmt);

    if (pBanned)
        pBanned->GetSession()->KickPlayer();

    return BAN_SUCCESS;
}

/// Remove a ban from a character
bool World::RemoveBanCharacter(std::string name)
{
    Player *pBanned = sObjectMgr.GetPlayer(name.c_str());
    uint32 guid = 0;

    /// Pick a player to ban if not online
    if (!pBanned)
    {
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_GET_GUID_BY_NAME);
        stmt->setString(0, name);
        PreparedQueryResult resultCharacter = CharacterDatabase.Query(stmt);

        if (!resultCharacter)
            return false;

        guid = (*resultCharacter)[0].GetUInt32();
    }
    else
        guid = pBanned->GetGUIDLow();

    if (!guid)
        return false;

    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SET_NOT_BANNED);
    stmt->setUInt32(0, guid);
    CharacterDatabase.Execute(stmt);
    return true;
}

/// Update the game time
void World::_UpdateGameTime()
{
    ///- update the time
    time_t thisTime = time(NULL);
    uint32 elapsed = uint32(thisTime - m_gameTime);
    m_gameTime = thisTime;

    ///- if there is a shutdown timer
    if (!m_stopEvent && m_ShutdownTimer > 0 && elapsed > 0)
    {
        ///- ... and it is overdue, stop the world (set m_stopEvent)
        if (m_ShutdownTimer <= elapsed)
        {
            if (!(m_ShutdownMask & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount() == 0)
                m_stopEvent = true;                         // exist code already set
            else
                m_ShutdownTimer = 1;                        // minimum timer value to wait idle state
        }
        ///- ... else decrease it and if necessary display a shutdown countdown to the users
        else
        {
            m_ShutdownTimer -= elapsed;

            ShutdownMsg();
        }
    }
}

/// Shutdown the server
void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode)
{
    // ignore if server shutdown at next tick
    if (m_stopEvent)
        return;

    m_ShutdownMask = options;
    m_ExitCode = exitcode;

    ///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions)
    if (time == 0)
    {
        if (!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount() == 0)
            m_stopEvent = true;                             // exist code already set
        else
            m_ShutdownTimer = 1;                            //So that the session count is re-evaluated at next world tick
    }
    ///- Else set the shutdown timer and warn users
    else
    {
        m_ShutdownTimer = time;
        ShutdownMsg(true);
    }

    sScriptMgr.OnShutdownInitiate(ShutdownExitCode(exitcode), ShutdownMask(options));
}

/// Display a shutdown message to the user(s)
void World::ShutdownMsg(bool show, Player* player)
{
    // not show messages for idle shutdown mode
    if (m_ShutdownMask & SHUTDOWN_MASK_IDLE)
        return;

    ///- Display a message every 12 hours, hours, 5 minutes, minute, 5 seconds and finally seconds
    if (show ||
        (m_ShutdownTimer < 10) ||
        (m_ShutdownTimer < 30 && (m_ShutdownTimer % 5) == 0) || // < 30 sec; every 5 sec
        (m_ShutdownTimer < 5 * MINUTE && (m_ShutdownTimer % MINUTE) == 0) || // < 5 min ; every 1 min
        (m_ShutdownTimer < 30 * MINUTE && (m_ShutdownTimer % (5 * MINUTE)) == 0) || // < 30 min ; every 5 min
        (m_ShutdownTimer < 12 * HOUR && (m_ShutdownTimer % HOUR) == 0) || // < 12 h ; every 1 h
        (m_ShutdownTimer > 12 * HOUR && (m_ShutdownTimer % (12 * HOUR)) == 0)) // > 12 h ; every 12 h
    {
        std::string str = secsToTimeString(m_ShutdownTimer);

        ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_TIME : SERVER_MSG_SHUTDOWN_TIME;

        SendServerMessage(msgid,str.c_str(),player);
        sLog.outStaticDebug("Server is %s in %s",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"),str.c_str());
    }
}

/// Cancel a planned server shutdown
void World::ShutdownCancel()
{
    // nothing cancel or too later
    if (!m_ShutdownTimer || m_stopEvent)
        return;

    ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_CANCELLED : SERVER_MSG_SHUTDOWN_CANCELLED;

    m_ShutdownMask = 0;
    m_ShutdownTimer = 0;
    m_ExitCode = SHUTDOWN_EXIT_CODE;                       // to default value
    SendServerMessage(msgid);

    sLog.outStaticDebug("Server %s cancelled.",(m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"));

    sScriptMgr.OnShutdownCancel();
}

/// Send a server message to the user(s)
void World::SendServerMessage(ServerMessageType type, const char *text, Player* player)
{
    WorldPacket data(SMSG_SERVER_MESSAGE, 50);              // guess size
    data << uint32(type);
    if (type <= SERVER_MSG_STRING)
        data << text;

    if (player)
        player->GetSession()->SendPacket(&data);
    else
        SendGlobalMessage(&data);
}

void World::UpdateSessions(uint32 diff)
{
    ///- Add new sessions
    WorldSession* sess;
    while (addSessQueue.next(sess))
        AddSession_ (sess);

    ///- Then send an update signal to remaining ones
    for (SessionMap::iterator itr = m_sessions.begin(), next; itr != m_sessions.end(); itr = next)
    {
        next = itr;
        ++next;

        ///- and remove not active sessions from the list
        WorldSession * pSession = itr->second;
        WorldSessionFilter updater(pSession);

        if(!pSession->Update(diff, updater))    // As interval = 0
        {
            if (!RemoveQueuedPlayer(itr->second) && itr->second && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))
                m_disconnects[itr->second->GetAccountId()] = time(NULL);
            RemoveQueuedPlayer(pSession);
            m_sessions.erase(itr);
            delete pSession;

        }
    }
}

// This handles the issued and queued CLI commands
void World::ProcessCliCommands()
{
    CliCommandHolder::Print* zprint = NULL;
    void* callbackArg = NULL;
    CliCommandHolder* command;
    while (cliCmdQueue.next(command))
    {
        sLog.outDebug("CLI command under processing...");
        zprint = command->m_print;
        callbackArg = command->m_callbackArg;
        CliHandler handler(callbackArg, zprint);
        handler.ParseCommands(command->m_command);
        if(command->m_commandFinished)
            command->m_commandFinished(callbackArg, !handler.HasSentErrorMessage());
        delete command;
    }
}

void World::SendAutoBroadcast()
{
    if (m_Autobroadcasts.empty())
        return;

    std::string msg;

    std::list<std::string>::const_iterator itr = m_Autobroadcasts.begin();
    std::advance(itr, rand() % m_Autobroadcasts.size());
    msg = *itr;

    uint32 abcenter = sWorld.getIntConfig(CONFIG_AUTOBROADCAST_CENTER);

    if (abcenter == 0)
        sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());

    else if (abcenter == 1)
    {
        WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1));
        data << msg;
        sWorld.SendGlobalMessage(&data);
    }
    else if (abcenter == 2)
    {
        sWorld.SendWorldText(LANG_AUTO_BROADCAST, msg.c_str());

        WorldPacket data(SMSG_NOTIFICATION, (msg.size()+1));
        data << msg;
        sWorld.SendGlobalMessage(&data);
    }
    sLog.outDebug("AutoBroadcast: '%s'",msg.c_str());
}

void World::UpdateRealmCharCount(uint32 accountId)
{
    m_realmCharCallback.SetParam(accountId);
    m_realmCharCallback.SetFutureResult(CharacterDatabase.AsyncPQuery("SELECT COUNT(guid) FROM characters WHERE account = '%u'", accountId));
}

void World::_UpdateRealmCharCount(QueryResult resultCharCount, uint32 accountId)
{
    if (resultCharCount)
    {
        Field *fields = resultCharCount->Fetch();
        uint32 charCount = fields[0].GetUInt32();

        LoginDatabase.PExecute("DELETE FROM realmcharacters WHERE acctid= '%d' AND realmid = '%d'", accountId, realmID);
        LoginDatabase.PExecute("INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (%u, %u, %u)", charCount, accountId, realmID);
    }
}

void World::InitWeeklyQuestResetTime()
{
    time_t wstime = uint64(sWorld.getWorldState(WS_WEEKLY_QUEST_RESET_TIME));
    time_t curtime = time(NULL);
    m_NextWeeklyQuestReset = wstime < curtime ? curtime : time_t(wstime);
}

void World::InitDailyQuestResetTime()
{
    time_t mostRecentQuestTime;

    QueryResult result = CharacterDatabase.Query("SELECT MAX(time) FROM character_queststatus_daily");
    if (result)
    {
        Field *fields = result->Fetch();
        mostRecentQuestTime = (time_t)fields[0].GetUInt64();
    }
    else
        mostRecentQuestTime = 0;

    // client built-in time for reset is 6:00 AM
    // FIX ME: client not show day start time
    time_t curTime = time(NULL);
    tm localTm = *localtime(&curTime);
    localTm.tm_hour = 6;
    localTm.tm_min  = 0;
    localTm.tm_sec  = 0;

    // current day reset time
    time_t curDayResetTime = mktime(&localTm);

    // last reset time before current moment
    time_t resetTime = (curTime < curDayResetTime) ? curDayResetTime - DAY : curDayResetTime;

    // need reset (if we have quest time before last reset time (not processed by some reason)
    if (mostRecentQuestTime && mostRecentQuestTime <= resetTime)
        m_NextDailyQuestReset = mostRecentQuestTime;
    else // plan next reset time
        m_NextDailyQuestReset = (curTime >= curDayResetTime) ? curDayResetTime + DAY : curDayResetTime;
}

void World::InitRandomBGResetTime()
{
    time_t bgtime = uint64(sWorld.getWorldState(WS_BG_DAILY_RESET_TIME));
    if (!bgtime)
        m_NextRandomBGReset = time_t(time(NULL));         // game time not yet init

    // generate time by config
    time_t curTime = time(NULL);
    tm localTm = *localtime(&curTime);
    localTm.tm_hour = getIntConfig(CONFIG_RANDOM_BG_RESET_HOUR);
    localTm.tm_min = 0;
    localTm.tm_sec = 0;

    // current day reset time
    time_t nextDayResetTime = mktime(&localTm);

    // next reset time before current moment
    if (curTime >= nextDayResetTime)
        nextDayResetTime += DAY;

    // normalize reset time
    m_NextRandomBGReset = bgtime < curTime ? nextDayResetTime - DAY : nextDayResetTime;

    if (!bgtime)
        sWorld.setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset));
}

void World::ResetDailyQuests()
{
    sLog.outDetail("Daily quests reset for all characters.");
    CharacterDatabase.Execute("DELETE FROM character_queststatus_daily");
    for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
        if (itr->second->GetPlayer())
            itr->second->GetPlayer()->ResetDailyQuestStatus();

    // change available dailies
    sPoolMgr.ChangeDailyQuests();
}

void World::LoadDBAllowedSecurityLevel()
{
    QueryResult result = LoginDatabase.PQuery("SELECT allowedSecurityLevel from realmlist WHERE id = '%d'", realmID);
    if (result)
        SetPlayerSecurityLimit(AccountTypes(result->Fetch()->GetUInt16()));
}

void World::SetPlayerSecurityLimit(AccountTypes _sec)
{
    AccountTypes sec = _sec < SEC_CONSOLE ? _sec : SEC_PLAYER;
    bool update = sec > m_allowedSecurityLevel;
    m_allowedSecurityLevel = sec;
    if (update)
        KickAllLess(m_allowedSecurityLevel);
}

void World::ResetWeeklyQuests()
{
    CharacterDatabase.Execute("DELETE FROM character_queststatus_weekly");
    for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
        if (itr->second->GetPlayer())
            itr->second->GetPlayer()->ResetWeeklyQuestStatus();

    m_NextWeeklyQuestReset = time_t(m_NextWeeklyQuestReset + WEEK);
    sWorld.setWorldState(WS_WEEKLY_QUEST_RESET_TIME, uint64(m_NextWeeklyQuestReset));

    // change available weeklies
    sPoolMgr.ChangeWeeklyQuests();
}

void World::ResetRandomBG()
{
    sLog.outDetail("Random BG status reset for all characters.");
    CharacterDatabase.Execute("DELETE FROM character_battleground_random");
    for(SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
        if (itr->second->GetPlayer())
            itr->second->GetPlayer()->SetRandomWinner(false);

    m_NextRandomBGReset = time_t(m_NextRandomBGReset + DAY);
    sWorld.setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset));
}

bool World::GetRealmLimit()
{
    return m_playerLimit;
}

void World::UpdateMaxSessionCounters()
{
    m_maxActiveSessionCount = std::max(m_maxActiveSessionCount,uint32(m_sessions.size()-m_QueuedPlayer.size()));
    m_maxQueuedSessionCount = std::max(m_maxQueuedSessionCount,uint32(m_QueuedPlayer.size()));
}

void World::LoadDBVersion()
{
    QueryResult result = WorldDatabase.Query("SELECT db_version, script_version, cache_id FROM version LIMIT 1");

    if (result)
    {
        Field *fields = result->Fetch();

        m_DBVersion              = fields[0].GetString();
        m_CreatureEventAIVersion = fields[1].GetString();

        // will be overwrite by config values if different and non-0
        m_int_configs[CONFIG_CLIENTCACHE_VERSION] = fields[2].GetUInt32();
    }

    if (m_DBVersion.empty())
        m_DBVersion = "Unknown world database.";

    if (m_CreatureEventAIVersion.empty())
        m_CreatureEventAIVersion = "Unknown creature EventAI.";
}

void World::ProcessStartEvent()
{
    isEventKillStart = true;
}

void World::ProcessStopEvent()
{
    isEventKillStart = false;
}

void World::UpdateAreaDependentAuras()
{
    SessionMap::const_iterator itr;
    for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
        if (itr->second && itr->second->GetPlayer() && itr->second->GetPlayer()->IsInWorld())
        {
            itr->second->GetPlayer()->UpdateAreaDependentAuras(itr->second->GetPlayer()->GetAreaId());
            itr->second->GetPlayer()->UpdateZoneDependentAuras(itr->second->GetPlayer()->GetZoneId());
        }
}

void World::LoadWorldStates()
{
    QueryResult result = CharacterDatabase.Query("SELECT entry, value FROM worldstates");

    if (!result)
    {
        barGoLink bar(1);
        bar.step();
        sLog.outString();
        sLog.outString(">> Loaded 0 world states.");
        return;
    }

    barGoLink bar(result->GetRowCount());
    uint32 counter = 0;

    do
    {
        Field *fields = result->Fetch();
        m_worldstates[fields[0].GetUInt32()] = fields[1].GetUInt64();
        bar.step();
        ++counter;
    } while (result->NextRow());

    sLog.outString();
    sLog.outString(">> Loaded %u world states.", counter);
}

// Setting a worldstate will save it to DB
void World::setWorldState(uint32 index, uint64 value)
{
    WorldStatesMap::const_iterator it = m_worldstates.find(index);
    if (it != m_worldstates.end())
        CharacterDatabase.PExecute("UPDATE worldstates SET value="UI64FMTD" where entry=%u", value, index);
    else
        CharacterDatabase.PExecute("INSERT INTO worldstates (entry, value) VALUES (%u,"UI64FMTD")", index, value);
    m_worldstates[index] = value;
}

uint64 World::getWorldState(uint32 index) const
{
    WorldStatesMap::const_iterator it = m_worldstates.find(index);
    return it != m_worldstates.end() ? it->second : 0;
}

void World::ProcessQueryCallbacks()
{
    QueryResult result;

    if (m_realmCharCallback.IsReady())
    {
        uint32 param = m_realmCharCallback.GetParam();
        m_realmCharCallback.GetResult(result);
        _UpdateRealmCharCount(result, param);
        m_realmCharCallback.FreeResult();
    }
}
